Fix downloading/exporting when overwriting file would not truncate
This commit is contained in:
parent
8af786f26d
commit
c80c378398
3 changed files with 15 additions and 3 deletions
|
|
@ -189,6 +189,19 @@ public class StoredFileHelper implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public SharpStream openAndTruncateStream() throws IOException {
|
||||
final SharpStream sharpStream = getStream();
|
||||
try {
|
||||
sharpStream.setLength(0);
|
||||
} catch (final Throwable e) {
|
||||
// we can't use try-with-resources here, since we only want to close the stream if an
|
||||
// exception occurs, but leave it open if everything goes well
|
||||
sharpStream.close();
|
||||
throw e;
|
||||
}
|
||||
return sharpStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether it's using the {@code java.io} API.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue