Giter Site home page Giter Site logo

trash-d's Introduction

Hey, I'm Steven

FOSS fan, anime connoisseur, programming polyglot, Trekkie, and whatever else I'm feeling this week

Check out my website!

trash-d's People

Contributors

andy5995 avatar ninedotnine avatar rushsteve1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

trash-d's Issues

Cannot trash directories on a different partition

From util.d:

void renameOrCopy(in string src, in string tgt) {
    try {
        src.rename(tgt);
    } catch (FileException e) {
        if (e.errno != EXDEV)
            throw e;

        src.copy(tgt);
        src.remove();
    }
}

Note that src.copy(tgt) only works for regular files — it'll throw EISDIR is src is a directory. A better approach here is to recursively copy and delete src.

failing to remove causes immediate exit

Small incompatibility with GNU rm.

There is an argument to be made that this is better behaviour,
but trashing empty directories is pretty innocuous anyway.

» tree          
.
├── d1
│   └── file
└── d2
2 directories, 1 file
» trash -d d1 d2
trash: cannot remove 'd1': Directory not empty
» tree
.
├── d1
│   └── file
└── d2
2 directories, 1 file
» rm -d d1 d2 
rm: cannot remove 'd1': Directory not empty
» tree
.
└── d1
    └── file
1 directory, 1 file

unable to trash special files on a different filesystem from TRASH_D_DIR

for example, trying to trash a pipe:

» mkfifo pipe
» ls -l
|rw-r--r-- 1 0 dan dan 23 mai 18:17 pipe|
» trash pipe 
trash: path was neither file or directory
trash: /media/trash/files/pipe: No such file or directory
» rm pipe
» ls -l 
»

This apparently only happens when TRASH_D_DIR is on a different filesystem from the file.

unable to delete files beginning with `-`

rm (and various other Unix tools) accept -- as a terminator for arguments,
allowing everything which appears after to be understood as a filename:

» touch -- -Z --xxx
» tree 
.
├── --xxx
└── -Z
0 directories, 2 files
» trash -- -Z
» trash -- --xxx
» tree
.
├── --xxx
└── -Z
0 directories, 2 files
» rm -- --xxx      
» rm -- -Z
» tree
.
0 directories, 0 files

trash-d crashes if directory is not writeable

» ls -l ..
dr-xr-xr-x 2 - dan dan  9 jun 16:45 trash-demo/
» trash file 
std.file.FileException@std/file.d(1073): Failed to remove file file: Permission denied
----------------
??:? @safe bool std.file.cenforce!(bool).cenforce(bool, scope lazy const(char)[], immutable(char)[], ulong) [0x55af000d0f14]
??:? @trusted void std.file.removeImpl(scope const(char)[], scope const(char)*) [0x55af000cfa1e]
??:? @safe void std.file.remove!(immutable(char)[]).remove(immutable(char)[]) [0x55af0006eb58]
??:? bool trash.util.renameOrCopy(in immutable(char)[], in immutable(char)[]) [0x55af00060f38]
??:? int trash.opers.trashOrRm(in immutable(char)[]) [0x55af00056675]
??:? int trash.run.runCommands(immutable(char)[][]) [0x55af00060bbe]
??:? _Dmain [0x55af0004ca92]
» 

Support Trash folders on alternate drives/partitions

This is a follow-up to #1

Currently trash-d will copy a file into the user's home trash folder when trashing a file on a different drive/partition. This isn't great from a speed and space perspective, nor from a compatibility one (though it is spec-compliant).

A future version of trash-d could enumerate /proc/mounts (or some other facility if D has one) to find out what device it is on, then use that information to find and use a .Trash folder on that device.

However this also poses a number of UX issues. trash --list would have to find and list the trash on every single device, trash --empty now has the potential for considerably more unintended damage. trash --del and trash --restore are now ambiguous if you have 2 files with the same name across different drives.

In addition to all this, it could substantially complicate trash-d's code since there would no longer be a single known trash directory. It could also possibly tie it even more tightly to Linux, and I would like to support the BSDs which would complicate things further.

This issue is for discussing the future of this feature, and in general determining whether or not it is worth doing. So questions, comments, and suggestions are welcome!

cannot trash broken soft links

» touch file 
» ln -s file link
» ls -l
-rw-r--r-- 1   0 dan dan 15 mai 23:39 file
lrwxrwxrwx 1   4 dan dan 15 mai 23:39 link -> file
» trash file  
» ls -l
lrwxrwxrwx 1   4 dan dan 15 mai 23:39 link -> file
» trash link
trash: link: No such file or directory
» ls -l
lrwxrwxrwx 1   4 dan dan 15 mai 23:39 link -> file

Broken links must be deleted with rm instead.

Show Orphaned Files and .trashinfos

Sometimes the trash directory can enter a somewhat inconsistent state where there are orphaned files that don't have matching .trashinfos or vice-versa. This seems to happen in various file managers and utilities (it's not specific to trash-d and I've never seen trash-d cause it), and appears to just be an edge case that can happen occasionally for whatever reason.

So it would be nice to have a way of listing and reporting the orphaned files so that the user is aware of them.

This idea comes from alphapapa/rubbish.py

Support trashing across filesystems

Currently trash-d omits the section of the Freedesktop specification about trash dirs on other devices (doing this is still technically compliant as far as I am aware)

However it would be nice to be able to trash files while on a mounted device or filesystem.
Doing so would require...

  • Get all the filesystems from /proc/mounts
  • Figure out what filesystem the file is on, and what the root of that mount is
  • If it isn't on the same filesystem as the user's home
  • Create a $topdir/.Trash-$uid folder and use that as the trash dir

In addition, now all trash commands like --empty would have to enumerate these directories and operate on them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.