From 945988dfb70991e2609fa1fc4be258b3bc39bfb0 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Wed, 5 Nov 2014 16:39:54 +0000
Subject: [PATCH] i2psnark: Fix NPE when deleting torrent if the data directory
 was deleted out from under us (ticket #1407)

---
 apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
index d0e6928d58..a1daeb4e47 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
@@ -1039,6 +1039,8 @@ public class I2PSnarkServlet extends BasicServlet {
                             }
                             // step 2 delete dirs bottom-up
                             Set<File> dirs = storage.getDirectories();
+                            if (dirs == null)
+                                break;  // directory deleted out from under us
                             if (_log.shouldLog(Log.INFO))
                                 _log.info("Dirs to delete: " + DataHelper.toString(dirs));
                             boolean ok = false;
-- 
GitLab