This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-trino.git
The following commit(s) were added to refs/heads/main by this push:
new da8c637 Avoid deleting directories including data during expired
snapshots (#88)
da8c637 is described below
commit da8c637264fe598e92116787292bf77309fdecbd
Author: rfyu <[email protected]>
AuthorDate: Tue Nov 26 13:22:14 2024 +0800
Avoid deleting directories including data during expired snapshots (#88)
---
.../src/main/java/org/apache/paimon/trino/fileio/TrinoFileIO.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git
a/paimon-trino-440/src/main/java/org/apache/paimon/trino/fileio/TrinoFileIO.java
b/paimon-trino-440/src/main/java/org/apache/paimon/trino/fileio/TrinoFileIO.java
index cfa7fcc..48d1f68 100644
---
a/paimon-trino-440/src/main/java/org/apache/paimon/trino/fileio/TrinoFileIO.java
+++
b/paimon-trino-440/src/main/java/org/apache/paimon/trino/fileio/TrinoFileIO.java
@@ -147,6 +147,11 @@ public class TrinoFileIO implements FileIO {
public boolean delete(Path path, boolean recursive) throws IOException {
Location location = Location.of(path.toString());
if (trinoFileSystem.directoryExists(location).orElse(false)) {
+ if (!recursive) {
+ if (trinoFileSystem.listFiles(location).hasNext()) {
+ throw new IOException("Directory " + location + " is not
empty");
+ }
+ }
trinoFileSystem.deleteDirectory(location);
return true;
} else if (existFile(location)) {