Skip to content

Commit 6838885

Browse files
committed
packs: remove partially installed pack folder
- if zip fails, remove the incomplete folder
1 parent f81696f commit 6838885

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

ilg.gnuarmeclipse.packs/src/ilg/gnuarmeclipse/packs/jobs/InstallJob.java

+18-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package ilg.gnuarmeclipse.packs.jobs;
1313

14+
import ilg.gnuarmeclipse.core.Activator;
1415
import ilg.gnuarmeclipse.core.StringUtils;
1516
import ilg.gnuarmeclipse.packs.core.ConsoleStream;
1617
import ilg.gnuarmeclipse.packs.core.data.PacksStorage;
@@ -258,11 +259,19 @@ private boolean installPack(Node versionNode) throws IOException {
258259
Utils.deleteFolderRecursive(destFolder);
259260
}
260261

261-
// Extract all files from the archive to the local folder.
262-
if (!unzip(archiveFile, destRelPath)) {
262+
boolean flag = false;
263+
try {
264+
flag = unzip(archiveFile, destRelPath);
265+
} catch (IOException e) {
266+
Activator.log(e);
267+
}
263268

269+
// Extract all files from the archive to the local folder.
270+
if (!flag) {
264271
fOut.println("Install cancelled due to errors.");
265272

273+
// Remove partial install
274+
Utils.deleteFolderRecursive(destFolder);
266275
return false;
267276
}
268277

@@ -342,9 +351,13 @@ private boolean unzip(File archiveFile, IPath destRelativePath)
342351

343352
zipInput.closeEntry();
344353
zipInput.close();
345-
fOut.println(countFiles + " files written, "
346-
+ StringUtils.convertSizeToString(countBytes) + ".");
347-
354+
if (countBytes > 0) {
355+
fOut.println(countFiles + " files written, "
356+
+ StringUtils.convertSizeToString(countBytes) + ".");
357+
} else {
358+
fOut.println("No files written.");
359+
result = false;
360+
}
348361
return result;
349362
}
350363

0 commit comments

Comments
 (0)