mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
feat(tasks): add a storage.delete tasks to allow deletion of internal storage file
This commit is contained in:
@@ -66,4 +66,14 @@ public class LocalStorage implements StorageInterface {
|
||||
|
||||
return URI.create("kestra://" + uri.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(URI uri) throws IOException {
|
||||
File file = getPath(URI.create(uri.getPath())).toFile();
|
||||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,5 +62,15 @@ class LocalStorageTest {
|
||||
CharStreams.toString(new InputStreamReader(get)),
|
||||
is(CharStreams.toString(new InputStreamReader(new FileInputStream(Objects.requireNonNull(resource).getFile()))))
|
||||
);
|
||||
|
||||
boolean delete = storageInterface.delete(new URI("/file/storage/put.yml"));
|
||||
assertThat(delete, is(true));
|
||||
|
||||
delete = storageInterface.delete(new URI("/file/storage/put.yml"));
|
||||
assertThat(delete, is(false));
|
||||
|
||||
assertThrows(FileNotFoundException.class, () -> {
|
||||
storageInterface.get(new URI("/file/storage/put.yml"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user