[Mayan EDMS: 2012] Rebuilding Files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 2012] Rebuilding Files

Gerrit Van Dyk
Hi

We have quite a lot of files that was scanned and processed at Grayscale, 300DPI with over 2000 pages.

These files are large in size, with some over 2GB per file.

Our clients has now decided that we can reduce the files in size and use a different compression algorithm.

We now want to run our code on the files that are stored within Mayan. We can do this with ease, but the metadata about file size etc needs to be updated.

How can we trigger an update on the metadata stored within Mayan on amount of pages, file size etc, about a file that already exists?

We do not want to load a new version, but would like to update the current version.

--

---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 2016] Re: Rebuilding Files

rosarior
Administrator
Hi,

You would need to execute the same methods that are called when a new document version is uploaded: https://gitlab.com/mayan-edms/mayan-edms/blob/master/mayan/apps/documents/models.py#L443

Code sample. Disclaimer: Haven't tried this before. Make backups and test extensively.

for document_version in DocumentVersion.objects.all():
    document_version.update_checksum(save=False)
    document_version.update_mimetype(save=False)
    document_version.save()
    document_version.update_page_count(save=False)
    document_version.save()

Document.objects.invalidate_cache()

.update_page_count() will delete the existing pages before introspecting the file again. This means anything with a foreign key to document pages will be deleted as well (OCR, transformations).

On Friday, August 11, 2017 at 6:06:20 AM UTC-4, Gerrit Van Dyk wrote:
Hi

We have quite a lot of files that was scanned and processed at Grayscale, 300DPI with over 2000 pages.

These files are large in size, with some over 2GB per file.

Our clients has now decided that we can reduce the files in size and use a different compression algorithm.

We now want to run our code on the files that are stored within Mayan. We can do this with ease, but the metadata about file size etc needs to be updated.

How can we trigger an update on the metadata stored within Mayan on amount of pages, file size etc, about a file that already exists?

We do not want to load a new version, but would like to update the current version.

--

---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.