Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Options.Rename;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
import org.apache.hadoop.fs.permission.FsPermission;
Expand Down Expand Up @@ -397,6 +398,32 @@ public boolean rename(Path src, Path dst) throws IOException {
return result;
}

/**
* Intercept rename to trash calls from TrashPolicyDefault,
* convert them to delete calls instead.
*/
@Deprecated
protected void rename(final Path src, final Path dst,
final Rename... options) throws IOException {
boolean hasMoveToTrash = false;
if (options != null) {
for (Rename option : options) {
if (option == Rename.TO_TRASH) {
hasMoveToTrash = true;
break;
}
}
}
if (!hasMoveToTrash) {
// if doesn't have TO_TRASH option, just pass the call to super
super.rename(src, dst, options);
} else {
// intercept when TO_TRASH is found
Comment thread
smengcl marked this conversation as resolved.
LOG.info("Move to trash is disabled for o3fs, deleting instead: {}", src);
delete(src, true);
}
}

private class DeleteIterator extends OzoneListingIterator {
private boolean recursive;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Options;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
import org.apache.hadoop.fs.permission.FsPermission;
Expand Down Expand Up @@ -372,6 +373,32 @@ public boolean rename(Path src, Path dst) throws IOException {
return result;
}

/**
* Intercept rename to trash calls from TrashPolicyDefault,
* convert them to delete calls instead.
*/
@Deprecated
protected void rename(final Path src, final Path dst,
final Options.Rename... options) throws IOException {
boolean hasMoveToTrash = false;
if (options != null) {
for (Options.Rename option : options) {
if (option == Options.Rename.TO_TRASH) {
hasMoveToTrash = true;
break;
}
}
}
if (!hasMoveToTrash) {
// if doesn't have TO_TRASH option, just pass the call to super
super.rename(src, dst, options);
} else {
// intercept when TO_TRASH is found
LOG.info("Move to trash is disabled for ofs, deleting instead: {}", src);
delete(src, true);
}
}

private class DeleteIterator extends OzoneListingIterator {
final private boolean recursive;
private final OzoneBucket bucket;
Expand Down