Ticket #1465: add_verify_single_file.patch

File add_verify_single_file.patch, 3.5 KB (added by pieter, 12 years ago)

patch

Line 
1Index: libtransmission/transmission.h
2===================================================================
3--- libtransmission/transmission.h      (revision 7108)
4+++ libtransmission/transmission.h      (working copy)
5@@ -1104,7 +1104,9 @@
6                                int                 size );
7 
8 void tr_torrentVerify( tr_torrent * torrent );
9+void tr_torrentVerifyUnchecked( tr_torrent * tor );
10 
11 /***********************************************************************
12  * tr_info
13  **********************************************************************/
14Index: libtransmission/torrent.c
15===================================================================
16--- libtransmission/torrent.c   (revision 7108)
17+++ libtransmission/torrent.c   (working copy)
18@@ -1194,6 +1194,18 @@
19     tr_globalUnlock( tor->session );
20 }
21 
22+void
23+tr_torrentVerifyUnchecked( tr_torrent * tor )
24+{
25+    tr_verifyRemove( tor );
26+
27+    tr_globalLock( tor->session );
28+
29+    tr_verifyAdd( tor, torrentRecheckDoneCB );
30+
31+    tr_globalUnlock( tor->session );
32+}
33+
34 static void
35 stopTorrent( void * vtor )
36 {
37Index: macosx/FileOutlineController.m
38===================================================================
39--- macosx/FileOutlineController.m      (revision 7108)
40+++ macosx/FileOutlineController.m      (working copy)
41@@ -281,6 +281,17 @@
42             [[fOutline itemAtRow: i] fullPath]] inFileViewerRootedAtPath: nil];
43 }
44 
45+- (void) validateFile: (id) sender
46+{
47+       NSIndexSet * indexSet = [fOutline selectedRowIndexes];
48+    NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
49+    for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
50+        [itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
51+       
52+       [fTorrent validateFilesWithIndexes: itemIndexes];
53+       [fOutline reloadData];
54+}
55+
56 #warning make real view controller (Leopard-only) so that Command-R will work
57 - (BOOL) validateMenuItem: (NSMenuItem *) menuItem
58 {
59@@ -440,6 +451,13 @@
60     
61     [menu addItem: [NSMenuItem separatorItem]];
62     
63+       // Validate selected file
64+       item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Validate file", "Validate a file")
65+                                                                         action:@selector(validateFile:) keyEquivalent: @""];
66+       [item setTarget: self];
67+       [menu addItem: item];
68+       [item release];
69+
70     //reveal in finder
71     item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Reveal in Finder", "File Outline -> Menu")
72             action: @selector(revealFile:) keyEquivalent: @""];
73Index: macosx/Torrent.h
74===================================================================
75--- macosx/Torrent.h    (revision 7108)
76+++ macosx/Torrent.h    (working copy)
77@@ -251,6 +251,8 @@
78 - (BOOL) hasFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
79 - (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
80 
81+- (void) validateFilesWithIndexes: (NSIndexSet *) indexSet;
82+
83 - (NSDate *) dateAdded;
84 - (NSDate *) dateCompleted;
85 - (NSDate *) dateActivity;
86Index: macosx/Torrent.m
87===================================================================
88--- macosx/Torrent.m    (revision 7108)
89+++ macosx/Torrent.m    (working copy)
90@@ -1537,6 +1537,15 @@
91     return priorities;
92 }
93 
94+- (void) validateFilesWithIndexes: (NSIndexSet *) indexSet
95+{
96+       for (NSInteger index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
97+               tr_torrentSetFileChecked(fHandle, index, 0);
98+
99+       tr_torrentVerifyUnchecked(fHandle);
100+       [self update];
101+}
102+
103 - (NSDate *) dateAdded
104 {
105     time_t date = fStat->addedDate;