Skip to content

Commit

Permalink
Improved error message for irregular file types
Browse files Browse the repository at this point in the history
When trashing an irregular file like a fifo pipe,
it cannot reliably be moved across filesystems.
Even cp seems to have issues with this.

Closes #12
  • Loading branch information
rushsteve1 committed Jun 6, 2022
1 parent 3eb6895 commit ea22475
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion source/trash/opers.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ int trashOrRm(in string path) {
log("trashing: %s", tfile.orig_path);

// Move the file to the trash files dir
path.renameOrCopy(tfile.file_path);
bool res = path.renameOrCopy(tfile.file_path);
if (!res)
return 1;

// Write the .trashinfo file
tfile.info_path.append(tfile.infoString);
Expand Down
6 changes: 4 additions & 2 deletions source/trash/util.d
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void createMissingFolders() {
needed.
Symlinks are NOT followed recursively
*/
void renameOrCopy(in string src, in string tgt) {
bool renameOrCopy(in string src, in string tgt) {
try {
// Bit of an odd workaround to prevent recursive trashing
if (src.endsWith("/") && src.chop().isSymlink) {
Expand All @@ -120,9 +120,11 @@ void renameOrCopy(in string src, in string tgt) {
}
src.rmdir();
} else {
err("path was neither file or directory");
err("'%s' is not a regular file and cannot be trashed across devices", src);
return false;
}
}
return true;
}

/**
Expand Down

0 comments on commit ea22475

Please sign in to comment.