i2psnark: Fix deletion of single-file torrent outside snark dir (ticket #1544)

This commit is contained in:
zzz
2015-05-13 14:00:19 +00:00
parent 081f1865a8
commit 1fb9643916
3 changed files with 17 additions and 11 deletions

View File

@@ -1047,19 +1047,20 @@ public class I2PSnarkServlet extends BasicServlet {
File f = new File(name); File f = new File(name);
f.delete(); f.delete();
_manager.addMessage(_("Torrent file deleted: {0}", f.getAbsolutePath())); _manager.addMessage(_("Torrent file deleted: {0}", f.getAbsolutePath()));
List<List<String>> files = meta.getFiles();
String dataFile = snark.getBaseName();
f = new File(_manager.getDataDir(), dataFile);
if (files == null) { // single file torrent
if (f.delete())
_manager.addMessage(_("Data file deleted: {0}", f.getAbsolutePath()));
else
_manager.addMessage(_("Data file could not be deleted: {0}", f.getAbsolutePath()));
break;
}
Storage storage = snark.getStorage(); Storage storage = snark.getStorage();
if (storage == null) if (storage == null)
break; break;
List<List<String>> files = meta.getFiles();
if (files == null) { // single file torrent
for (File df : storage.getFiles()) {
// should be only one
if (df.delete())
_manager.addMessage(_("Data file deleted: {0}", df.getAbsolutePath()));
else
_manager.addMessage(_("Data file could not be deleted: {0}", df.getAbsolutePath()));
}
break;
}
// step 1 delete files // step 1 delete files
for (File df : storage.getFiles()) { for (File df : storage.getFiles()) {
if (df.delete()) { if (df.delete()) {

View File

@@ -1,3 +1,8 @@
2015-05-13 zzz
* Console: Fix URLs caught in XSS filter on /confighome (ticket #1569)
* i2psnark: Fix deletion of single-file torrent outside snark dir (ticket #1544)
* NTCP: Catch race in Reader (ticket #1534)
2015-02-12 dg 2015-02-12 dg
* Job Queue/stats: add stat/graph for amount of scheduled jobs (router.tunnelBacklog) * Job Queue/stats: add stat/graph for amount of scheduled jobs (router.tunnelBacklog)
* FloodfillMonitorJob: * FloodfillMonitorJob:

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 21; public final static long BUILD = 22;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";