Tracking files accross rename/ move / etc?

Hi!

I’ve recently come upon a use case where being able to track a file’s life-cycle across e.g. “rename”, “move” etc. is necessary. I had hopes that a smart-link to the file might actually remain the same or old smart-links be tracked to resolve to the newest, but this doesn’t seem possible?

E.g.

  • create a file test.md in a directory and copy “internal link”
  • rename the file to test2.md, copy internal link and compare both → they are different
  • old internal link doesn’t resolve to renamed file

Same goes for moving the file into a sub-directory or the like.

I then tried via api-endpoints /api2/repos/{repo_id}/file/detail and …/file/history, and while there is information encoded such as id, parent_id, root_id etc., I can’t make sense of it beyond the obvious (once renamed, the former id becomes parent_id and a new id is given, etc.) since I didn’t find a way to call the API searching via a file id, which would have enabled me to do a recursive search or similar.

So I guess my question is: Is there a way to create “eternal (internal) file links” that will remain the same no matter what is happening to the file until it is deleted and trash is emptied? Or maybe a way to search for old smart-links, find the current file-id and generate the latest smart-link?

Thanks!

smart-link will be point to the same file across rename/move. Maybe it is caused by that your file for testing is empty. Empty files cannot be tracked currently.

Hey @daniel.pan

Great catch! It was indeed an empty test file. With content, the smart-link indeed tracks it across renames and moves. Great!

One limitation though, and some unexpected behaviour:

If the file is moved outside of the library int another, the smart-link doesn’t resolve anymore. Moving it back will also not resolve UNLESS it’s moved back to the same spot it was in last with the same name. But that’s something we can live with.

Also, is there a way to search for files using their internal IDs? If not via the API or interface, then maybe via database? Just wondering…

Thank you for the quick heads-up!

In seahub_db, there is a table tags_fileuuidmap, that mapping the internal IDs to the file path.

1 Like

Cheers @daniel.pan , that’s perfect!