Skip to content

Commit 17747b3

Browse files
committed
WIP FileWorkspaceMap support
1 parent 8fa1e61 commit 17747b3

3 files changed

Lines changed: 531 additions & 544 deletions

File tree

src/main/java/picoded/dstack/FileWorkspace.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ default void writeInputStream(final String filepath, final InputStream data) {
167167
rawBytes = IOUtils.toByteArray(data);
168168
} catch (IOException e) {
169169
throw new RuntimeException(e);
170+
} finally {
171+
try {
172+
data.close();
173+
} catch (IOException e) {
174+
throw new RuntimeException(e);
175+
}
170176
}
171177
// Does the bytearray writes
172178
writeByteArray(filepath, rawBytes);

src/main/java/picoded/dstack/core/Core_FileWorkspaceMap.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void setupWorkspace(String oid) {
181181
* @param ObjectID of workspace
182182
* @param filepath to use for the workspace
183183
*
184-
* @return the stored byte array of the file
184+
* @return the stored byte stream of the file
185185
**/
186186
public InputStream backend_fileReadInputStream(final String oid, final String filepath) {
187187
// Get the byte data
@@ -218,6 +218,12 @@ public void backend_fileWriteInputStream(final String oid, final String filepath
218218
rawBytes = IOUtils.toByteArray(data);
219219
} catch (IOException e) {
220220
throw new RuntimeException(e);
221+
} finally {
222+
try {
223+
data.close();
224+
} catch (IOException e) {
225+
throw new RuntimeException(e);
226+
}
221227
}
222228

223229
// Does the bytearray writes

0 commit comments

Comments
 (0)