Skip to content

Commit

Permalink
trim metadata from windows server #1383
Browse files Browse the repository at this point in the history
  • Loading branch information
bblemm authored and frankdejonge committed Nov 25, 2021
1 parent 8f7d625 commit 218446b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Adapter/AbstractFtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ protected function normalizeWindowsObject($item, $base)
*/
protected function detectSystemType($item)
{
return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item) ? 'windows' : 'unix';
return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', trim($item)) ? 'windows' : 'unix';
}

/**
Expand Down
17 changes: 16 additions & 1 deletion tests/FtpTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function ftp_chdir($connection, $directory)
'file2.txt',
'file3.txt',
'file4.txt',
'file5WithPadding.txt',
'dir1',
'file1.with-total-line.txt',
'file1.with-invalid-line.txt',
Expand All @@ -128,7 +129,7 @@ function ftp_raw($connection, $command)
if ($connection === 'utf8.alreadyActive') {
return [0 => '202 UTF8 mode is always enabled. No need to send this command.'];
}

return [0 => '200 UTF8 set to on'];
}

Expand Down Expand Up @@ -229,6 +230,12 @@ function ftp_rawlist($connection, $directory)
];
}

if (strpos($directory, 'file5WithPadding.txt') !== false) {
return [
' 2016-05-23 12:09PM 685 file5WithPadding.txt',
];
}

if (strpos($directory, 'dir1') !== false) {
return [
'2015-05-23 12:09 <DIR> dir1',
Expand Down Expand Up @@ -568,6 +575,14 @@ public function testGetWindowsMetadata()
$this->assertEquals('public', $metadata['visibility']);
$this->assertEquals(684, $metadata['size']);

$metadata = $adapter->getMetadata('file5WithPadding.txt');
$this->assertIsArray($metadata);
$this->assertEquals('file', $metadata['type']);
$this->assertEquals('file5WithPadding.txt', $metadata['path']);
$this->assertEquals(1464005340, $metadata['timestamp']);
$this->assertEquals('public', $metadata['visibility']);
$this->assertEquals(685, $metadata['size']);

$metadata = $adapter->getMetadata('dir1');
$this->assertEquals('dir', $metadata['type']);
$this->assertEquals('dir1', $metadata['path']);
Expand Down

0 comments on commit 218446b

Please sign in to comment.