DDK-100: Sets timestamps on files (going forward)
The main change here is to begin setting created_at
and updated_at
for Ddr::File
objects persisted via the add_file
method of Ddr::FileManagement
(included in Ddr::ResourceChangeSet
). Due to the complexity of managing files with the current code, I decided not to remediate existing files, but instead to provide a sort of bridge API for accessing timestamps on all files. Ddr::File::Timestamps
is a Struct with :created
and :updated
fields return either the created_at
/updated_at
attribute, respectively, if set; otherwise return the ctime/mtime from the stat info for the file on disk. This allows us to move forward with setting the CONTENT_CREATE_DATE
index field (to resource.content.timestamps.created
) without having to explicitly set created_at
on all files.
I have also decided to begin setting new_record
to false
on a persisted file (i.e., it has been "uploaded" and received an identifier from the storage). Again, the existing files will not be directly remediated, but we have instead overridden Valkyrie::Resource#persisted?
to return true
if new_record
is false
(via super
) OR file_identifier&.id
is present. Although we have ignored new_record
and persisted?
for files, and we don't persist Ddr::File
records separately from the resources to which the files are attached, it seems better to make the attribute and method accurately reflect the persistence status of the file (bytes).
Additional changes reflect some refactoring (e.g., moving Ddr::Files
from lib/
to app/models/
and eliminating some not-reused "concern" modules), and I have also filled in some method documentation to hopefully make some of the file management code easier to read. There is more work to be done!