Get filename from UUID (DB lost)

Questions, comments, discussions. Over time certain topics might be moved to their own category.
Post Reply
Antho
Posts: 3
Joined: Sun Dec 01, 2019 12:02 am
Location: France

Get filename from UUID (DB lost)

Post by Antho » Sun Dec 01, 2019 12:11 am

Hello,

Do you know if this is possible to get the original title of a file with the UUID?

Indeed, I lost my DB (no backup) but I have a backup of all datas files (including the document_storage directory).

I can see on https://docs.mayan-edms.com/topics/storage.html that all files are renamed to a specific UUID but I cannot find information how this UUID is generated.

Could you tell me how it is generated? So that I can try to restore the original filenames/reimport them...

Best regards,

pleblancq
Posts: 9
Joined: Sat Oct 26, 2019 2:09 pm

Re: Get filename from UUID (DB lost)

Post by pleblancq » Sun Dec 01, 2019 1:12 pm

Without the DB you can't restore the original filenames.

The UUID is the information needed to go in the table to retrieve the filenames.


exemple from mine:

29 | 88a6373a-7b3c-4004-abc0-c227f2974f4a | Invoice_000608.pdf | | 2019-10-28 13:06:11.345902-04 | eng | 3 | f | | f

then you pair it with documents_documentversion

29 | 2019-10-28 13:06:11.365221-04 | | ed5a58e0-89d8-4e80-a64b-7f65e680d884 | application/pdf | binary | 3ed2e500ab27dc851c469dc2f31aa3ed7b5b5374c06ec62b456434cd771af56f | 29

so if I go in document_storage, the the ID of the filename is ed5a58e0-89d8-4e80-a64b-7f65e680d884

Antho
Posts: 3
Joined: Sun Dec 01, 2019 12:02 am
Location: France

Re: Get filename from UUID (DB lost)

Post by Antho » Sun Dec 01, 2019 7:34 pm

Thank you for your answer.

Indeed, I just find the uuid "function" in the sources (especially https://gitlab.com/mayan-edms/mayan-edm ... 5dca4fa4ff and according to the python documentation (https://docs.python.org/2/library/uuid.html#uuid.uuid4), the uuid is generated randomly so no way to recover the title :( )

In this case, I will rename all files based on the content-type (extension) & I will try to generate a new title based on OCR or sort documents based on OCR...

User avatar
rosarior
Posts: 457
Joined: Tue Aug 21, 2018 3:28 am

Re: Get filename from UUID (DB lost)

Post by rosarior » Sun Dec 01, 2019 11:57 pm

Hi,

I'm sorry to read you lost your database. When Mayan was initially created storage provisioning and storage technologies were not what they are today.

One of the big problems of the time that defined the design decision was filename collisions. This was a problem nobody was tackling and is the reason we went with the most usable and compatible choice regardless of operating system or physical storage technology. It is so simple it even works with FAT32 formatted disks and as we allow subclassing the storage driver, things like sharding and segmentation can be done at the application level, even if they are not supported by the OS.

Things have changed since then and we have been figuring out ways to give users more control over how the document files are named. The branch filename_generators was created a few weeks ago to start working on this: https://gitlab.com/mayan-edms/mayan-edm ... generators

We have taken on this challenge and hope to have it finished in time for version 4.0.

Mcneece
Posts: 1
Joined: Sat Nov 30, 2019 9:41 am

Re: Get filename from UUID (DB lost)

Post by Mcneece » Mon Dec 02, 2019 3:04 pm

Will you be adding even more functionality to the filename_generators in the future, Rosarior?

User avatar
rosarior
Posts: 457
Joined: Tue Aug 21, 2018 3:28 am

Re: Get filename from UUID (DB lost)

Post by rosarior » Thu Dec 05, 2019 6:51 am

Yes, the branch adds support for specifying custom classes that will produce different document version filenames. This way users can choose to disable Mayan's default UUID filename assignment and opt to preserve the original filename of the document. Filename collisions will be handled by the storage layer.
Last edited by rosarior on Thu Dec 05, 2019 11:43 pm, edited 1 time in total.

Antho
Posts: 3
Joined: Sun Dec 01, 2019 12:02 am
Location: France

Re: Get filename from UUID (DB lost)

Post by Antho » Thu Dec 05, 2019 3:19 pm

Good to know @rosarior !

On my side, when I will re-install Mayan in the next days, I will add a cron for the backups this time :lol:

Post Reply