Merge "archive: Release resources before returning"
This commit is contained in:
commit
543b8560ac
|
@ -78,15 +78,17 @@ class Archive extends TextBuiltin {
|
|||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final TreeWalk walk = new TreeWalk(db);
|
||||
final ObjectReader reader = walk.getObjectReader();
|
||||
final MutableObjectId idBuf = new MutableObjectId();
|
||||
final Archiver fmt = formats.get(format);
|
||||
final ArchiveOutputStream outa = fmt.createArchiveOutputStream(outs);
|
||||
|
||||
if (tree == null)
|
||||
throw die(CLIText.get().treeIsRequired);
|
||||
|
||||
final ArchiveOutputStream outa = fmt.createArchiveOutputStream(outs);
|
||||
final TreeWalk walk = new TreeWalk(db);
|
||||
final ObjectReader reader = walk.getObjectReader();
|
||||
|
||||
try {
|
||||
walk.reset();
|
||||
walk.addTree(tree);
|
||||
walk.setRecursive(true);
|
||||
|
@ -102,9 +104,11 @@ protected void run() throws Exception {
|
|||
walk.getObjectId(idBuf, 0);
|
||||
fmt.putEntry(name, mode, reader.open(idBuf), outa);
|
||||
}
|
||||
|
||||
} finally {
|
||||
reader.release();
|
||||
outa.close();
|
||||
}
|
||||
}
|
||||
|
||||
static private void warnArchiveEntryModeIgnored(String name) {
|
||||
System.err.println(MessageFormat.format( //
|
||||
|
|
Loading…
Reference in New Issue