Files
nairobi/app/models
Javi Martín 930bb753c5 Use a rake task to delete cached attachments
Our previous system to delete cached attachments didn't work for
documents because the `custom_hash_data` is different for files created
from a file and files created from cached attachments.

When creating a document attachment, the name of the file is taken into
account to calculate the hash. Let's say the original file name is
"logo.pdf", and the generated hash is "123456". The cached attachment
will be "123456.pdf", so the generated hash using the cached attachment
will be something different, like "28af3". So the file that will be
removed will be "28af3.pdf", and not "123456.pdf", which will still be
present.

Furthermore, there are times where users choose a file and then they
close the browser or go to a different page. In those cases, we weren't
deleting the cached attachments either.

So we're adding a rake task to delete these files once a day. This way
we can simplify the logic we were using to destroy cached attachments.

Note there's related a bug in documents: when editing a record (for
example, a proposal), if the title of the document changes, its hash
changes, and so it will be impossible to generate a link to that
document. Changing the way this hash is generated is not an option
because it would break links to existing files. We'll try to fix it when
moving to Active Storage.
2021-07-30 17:30:11 +02:00
..
2021-06-03 11:13:52 +02:00
2021-03-02 13:15:15 +01:00
2021-03-02 13:15:15 +01:00
2020-10-15 14:57:42 +02:00
2020-12-16 11:43:17 +01:00
2021-04-08 17:23:30 +02:00
2020-10-15 14:57:42 +02:00
2019-03-27 15:22:14 +01:00
2021-04-13 13:52:18 +02:00
2020-12-15 11:57:09 +01:00
2019-10-23 14:39:31 +02:00
2019-03-14 17:25:43 +01:00
2019-04-29 13:08:43 -05:00
2020-12-21 18:04:48 +01:00
2020-12-02 12:13:02 +01:00
2020-04-09 07:11:53 +10:00
2019-02-05 17:41:00 +01:00
2019-10-25 19:29:12 +02:00
2017-12-15 19:21:02 +01:00
2021-01-12 14:50:37 +01:00