Open 1nsp1r3rnzt opened 1 year ago
Thank you!
Being able to sort by deletion date would be a very useful feature indeed. Unfortunately, it's currently not possible to get the deletion date through Obsidian's file API, which makes the feature difficult to implement reliably. I'm gonna add a little background info here because this blocks implementing #2 as well.
Obsidian provides the "mtime" and "ctime" timestamps for each file. mtime means "modification time", which updates when the file contents are modified, but ctime is platform-dependent. On Linux/Mac it updates when the contents or attributes change, on Windows it's the creation time. Neither of these can reliably be used as a deletion date.
So we'll have to track deletion ourselves. One possible implementation would be something like:
.trash
with a timestamp.trash
, add an entry with the path and the current time (effectively the deletion date).trash
to prevent newly deleted files from inheriting a deletion date from a previously deleted file with the same pathThis would work as long as files are deleted from within Obsidian, but there are some cases that will produce an incorrect deletion date, for instance:
.trash
), the deletion date will be whenever the plugin next runs its detection logic.trash
), the plugin won't see that it's actually a new file, and will reuse the old deletion dateThese scenarios are probably convoluted enough that the issues are acceptable, but it's important to acknowledge that Obsidian's vaults are supposed to be interoperable.
Additionally, Obsidian Sync won't sync the .trash folder, but synchronization tools like iCloud will, so the plugin needs to prevent two machines from overwriting each other's deletion dates. Either it will have to distinguish between sync providers (and reuse the deletion dates only when the .trash
folder is synced) or disable reusing deletion dates from other machines entirely.
So there are a couple of challenges associated with this feature. If anyone wants to take a stab at implementing it or has ideas for a more reliable technique, let me know :)
Thanks for following up. I see Obsidian has API limitations. Also, it seems that the feature needs different implementation for each OS. For my use case, I thought another idea might be to provide search bar at the top so a user can filter the file they want to restore. They can search by file name in the shown files list which will easily help to find the deleted file. It's the next good enough solution I thought.
Hi again, I just released a new version of the plugin that contains a search bar. I hope it's of use to you :)
I would love to see the ability to sort deleted files by date . This would be incredibly helpful for managing and organizing files within the plugin. The ideal outcome is to have the recently deleted files at the top of the list. It's useful to quickly restore an accidently deleted file.
Also, your plugin been an invaluable tool for me and I appreciate the effort you have put into creating and maintaining it.