Bug 43078: Include longname and perms keys in FTP's NLST fallback listing

The MLSD path, SFTP, and Local always return all six documented
list_files() keys (filename, longname, size, perms, mtime, type) - undef
where the value is unknown, but the key always present. The NLST
fallback path (servers without MLSD support) only set filename, size,
mtime and type, omitting longname and perms entirely rather than
setting them to undef.

Functionally harmless for consumers reading $file->{perms} (Perl
returns undef for a missing hash key too), but it breaks the "same flat
shape" contract this bug established, and would trip up any consumer
using exists() instead of defined() to check for a key.

Test plan:
1. prove t/db_dependent/Koha/File/Transport/FTP.t
   => All tests successful, including the new assertion that longname
      and perms keys are present (as undef) on the NLST fallback path.
2. koha-qa.pl -v 2 --more-tests
   => [PASS], no critic/pod warnings.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2026-07-16 15:12:15 +01:00 committed by Lucas Gass
parent 2f1eb2db84
commit 4f39b08db6
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 8 additions and 1 deletions

View File

@ -232,7 +232,9 @@ sub _list_files {
my $size = $self->{connection}->size($name);
push @file_list, {
filename => $name,
longname => undef,
size => $size,
perms => undef,
mtime => $self->{connection}->mdtm($name),
type => defined $size ? 'file' : 'directory',
};

View File

@ -211,7 +211,7 @@ subtest 'list_files() MLSD tests' => sub {
};
subtest 'list_files() NLST fallback tests' => sub {
plan tests => 10;
plan tests => 11;
$schema->storage->txn_begin;
@ -277,6 +277,11 @@ subtest 'list_files() NLST fallback tests' => sub {
is( $subdir->{type}, 'directory', 'SIZE failing is treated as a directory' );
is( $subdir->{perms}, undef, 'perms stay undef on the NLST fallback path' );
ok(
exists( $quote->{longname} ) && exists( $quote->{perms} ),
'longname and perms keys are present (as undef) on the NLST fallback path, matching the MLSD/SFTP/Local shape'
);
$transport->{connection} = undef;
$schema->storage->txn_rollback;