Changeset 7687
- Timestamp:
- Jan 12, 2009, 7:58:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r7663 r7687 20 20 #include <string.h> /* memcmp */ 21 21 #include <stdlib.h> /* qsort */ 22 23 #include <event.h> /* evbuffer */ 22 24 23 25 #include "transmission.h" … … 1130 1132 1131 1133 static void 1134 tr_torrentCloseLocalFiles( const tr_torrent * tor ) 1135 { 1136 tr_file_index_t i; 1137 struct evbuffer * buf = evbuffer_new( ); 1138 1139 for( i=0; i<tor->info.fileCount; ++i ) 1140 { 1141 const tr_file * file = &tor->info.files[i]; 1142 evbuffer_drain( buf, EVBUFFER_LENGTH( buf ) ); 1143 evbuffer_add_printf( buf, "%s%s%s", tor->downloadDir, TR_PATH_DELIMITER_STR, file->name ); 1144 tr_fdFileClose( (const char*) EVBUFFER_DATA( buf ) ); 1145 } 1146 1147 evbuffer_free( buf ); 1148 } 1149 1150 1151 static void 1132 1152 stopTorrent( void * vtor ) 1133 1153 { 1134 tr_file_index_t i; 1135 1136 tr_torrent * tor = vtor; 1154 tr_torrent * tor = vtor; 1137 1155 1138 1156 tr_verifyRemove( tor ); … … 1140 1158 tr_trackerStop( tor->tracker ); 1141 1159 1142 for( i = 0; i < tor->info.fileCount; ++i ) 1143 { 1144 const tr_file * file = &tor->info.files[i]; 1145 char * path = tr_buildPath( tor->downloadDir, file->name, NULL ); 1146 tr_fdFileClose( path ); 1147 tr_free( path ); 1148 } 1160 tr_torrentCloseLocalFiles( tor ); 1149 1161 } 1150 1162 … … 1278 1290 1279 1291 tor->completeness = completeness; 1292 tr_torrentCloseLocalFiles( tor ); 1280 1293 fireCompletenessChange( tor, completeness ); 1281 1294 … … 1855 1868 walkLocalData( tor, root, root, NULL, &torrentFiles, &folders, &dirtyFolders ); 1856 1869 1857 /* close all the files because we're about to delete them */1858 for( f=0; f<tor->info.fileCount; ++f ) {1859 char * path = tr_buildPath( tor->downloadDir, tor->info.files[f].name, NULL );1860 tr_fdFileClose( path );1861 tr_free( path );1862 }1863 1864 1870 /* try to remove entire folders first, so that the recycle bin will be tidy */ 1865 1871 s = (char**) tr_ptrArrayPeek( &folders, &n ); … … 1904 1910 fileFunc = unlink; 1905 1911 1912 /* close all the files because we're about to delete them */ 1913 tr_torrentCloseLocalFiles( tor ); 1914 1906 1915 if( tor->info.fileCount > 1 ) 1907 1916 deleteLocalData( tor, fileFunc ); … … 1909 1918 /* torrent only has one file */ 1910 1919 char * path = tr_buildPath( tor->downloadDir, tor->info.files[0].name, NULL ); 1911 tr_fdFileClose( path );1912 1920 fileFunc( path ); 1913 1921 tr_free( path );
Note: See TracChangeset
for help on using the changeset viewer.