EPrints Technical Mailing List Archive
See the EPrints wiki for instructions on how to join this mailing list and related information.
Message: #10198
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
[EP-tech] UNSUBSCRIBE
- To: "eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>
- Subject: [EP-tech] UNSUBSCRIBE
- From: "mark@wakadigital.co.nz" <mark@wakadigital.co.nz>
- Date: Wed, 6 Aug 2025 21:14:30 +0000
CAUTION: This e-mail originated outside the University of Southampton.
From: eprints-tech-request@ecs.soton.ac.uk <eprints-tech-request@ecs.soton.ac.uk> on behalf of Robin Sylvestre <robin.sylvestre@polymtl.ca>
Sent: Thursday, August 7, 2025 6:56 AM To: David R Newman <drn@ecs.soton.ac.uk>; eprints-tech@ecs.soton.ac.uk <eprints-tech@ecs.soton.ac.uk> Subject: RE: [EP-tech] Renaming files
CAUTION: This e-mail originated outside the University of Southampton.
CAUTION: This e-mail originated outside the University of Southampton.
Hi David,
Unfortunately this is not exactly what we need, we want filenames to be derived from eprint metadata.
I kinda succeeded to get the files to be renamed correctly, but I stille have some issues.
First setting $basename to a string taken from metadata through eprint_fields_automatic then
my $new_filename = $basename . $extension;
my $fileobj = $doc->get_value("files")->[0]; return unless $fileobj;
my $old_path = $fileobj->get_local_copy;
unless ( -e $old_path ) { print $fh "File not found : $old_path"; return; }
my $newfile = $doc->add_file( $old_path, $new_filename );
print $fh "success: $newfile\n";
if ($newfile) { my $files = $doc->get_value("files"); $doc->set_main($new_filename); $fileobj->remove();
$doc->commit(); } }
The problem with this is that when $fileobj->remove() is called, both files are deleted, while just the first one should be deleted. I need to test it more thoroughly to make sure files don’t get deleted especially when this is called for various reasons…
Robin
De : David R Newman <drn@ecs.soton.ac.uk>
Hi Robin, I am not aware of any conventional way to do this. It has not been a requirement I am aware of anyone else requiring, except for maybe better protection from using filenames that either are invalid in the filesystem or liable to cause different values being stored in the database and filesystem. I did add a configuration option to EPrints: $c->{generic_filenames} = 1; For the purpose of better protection against unusual filenames. With this setting on, all files would be stored in the same path as before but with the filename <fileid>.bin. Although you could change this for a pre-existent repository, it is more intended for new repositories, as having a mish-mash of different ways of setting the filename may have unintended consequences, which are difficult to test pre-emptively. The way generic_filenames has been implemented, files would still be served as the filename they were uploaded but you only need worry about changing the name of the file in the database rather than needing code that would also update the filename in the filesystem. Therefore, it may be easier to get closer to your solution using this feature. However, as the filename on disk needs to either match the filename in the database or <fileid>.bin, then this is not really suited for an existing repository, as you would need to manually update all existing documents to meet the <fileid>.bin filename format. Regards David Newman
On 04/08/2025 17:04, Robin Sylvestre wrote:
|
- References:
- [EP-tech] Renaming files
- From: Robin Sylvestre <robin.sylvestre@polymtl.ca>
- Re: [EP-tech] Renaming files
- From: David R Newman <drn@ecs.soton.ac.uk>
- RE: [EP-tech] Renaming files
- From: Robin Sylvestre <robin.sylvestre@polymtl.ca>
- [EP-tech] Renaming files
- Prev by Date: RE: [EP-tech] Renaming files
- Next by Date: Re: [EP-tech] Assistance Required: Error While Uploading Article via DOI
- Previous by thread: RE: [EP-tech] Renaming files
- Next by thread: [EP-tech] Assistance Required: Error While Uploading Article via DOI
- Index(es):