Skip to content

Commit

Permalink
FileSystemResourceManager.write close OutputStream
Browse files Browse the repository at this point in the history
transferStreams() already closes stream, but in case of Exception that
could be to late.
  • Loading branch information
EcljpseB0T authored and jukzi committed Jun 15, 2023
1 parent babb9ea commit 1809821
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1172,14 +1172,18 @@ public void write(IFile target, InputStream content, IFileInfo fileInfo, int upd
subMonitor.split(1);
}
int options = append ? EFS.APPEND : EFS.NONE;
OutputStream out = store.openOutputStream(options, subMonitor.split(1));
if (restoreHiddenAttribute) {
fileInfo.setAttribute(EFS.ATTRIBUTE_HIDDEN, true);
store.putInfo(fileInfo, EFS.SET_ATTRIBUTES, subMonitor.split(1));
} else {
subMonitor.split(1);
try (OutputStream out = store.openOutputStream(options, subMonitor.split(1))) {
if (restoreHiddenAttribute) {
fileInfo.setAttribute(EFS.ATTRIBUTE_HIDDEN, true);
store.putInfo(fileInfo, EFS.SET_ATTRIBUTES, subMonitor.split(1));
} else {
subMonitor.split(1);
}
FileUtil.transferStreams(content, out, store.toString(), subMonitor.split(1));
} catch (IOException e) {
String msg = NLS.bind(Messages.localstore_couldNotWrite, store.toString());
throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, new Path(store.toString()), msg, e);
}
FileUtil.transferStreams(content, out, store.toString(), subMonitor.split(1));
// get the new last modified time and stash in the info
lastModified = store.fetchInfo().getLastModified();
ResourceInfo info = ((Resource) target).getResourceInfo(false, true);
Expand Down

0 comments on commit 1809821

Please sign in to comment.