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