Fix: Dateigrößen mit glob+filesize statt dol_dir_list (korrigiert 0B Bug) [deploy]
All checks were successful
Deploy bericht / deploy (push) Successful in 5s
All checks were successful
Deploy bericht / deploy (push) Successful in 5s
This commit is contained in:
parent
0682b6ce37
commit
74e4509eee
1 changed files with 20 additions and 15 deletions
|
|
@ -163,24 +163,29 @@ $cmd->fetch_thirdparty();
|
|||
if (method_exists($cmd, 'fetch_optionals')) $cmd->fetch_optionals();
|
||||
|
||||
if ($action === 'photos') {
|
||||
// Anhänge des Auftrags
|
||||
// Anhänge des Auftrags — verwende glob statt dol_dir_list für korrektes filesize
|
||||
$upload_dir = $conf->commande->multidir_output[$cmd->entity].'/'.dol_sanitizeFileName($cmd->ref);
|
||||
error_log('[BERICHT] upload_dir: '.$upload_dir.' exists: '.(is_dir($upload_dir) ? 'yes' : 'no'));
|
||||
$files = is_dir($upload_dir)
|
||||
? dol_dir_list($upload_dir, 'files', 1, '', '(\.meta|_preview.*\.png|thumbs)$')
|
||||
: array();
|
||||
error_log('[BERICHT] dol_dir_list returned '.count($files).' files');
|
||||
$out = array();
|
||||
foreach ($files as $f) {
|
||||
error_log('[BERICHT] file: '.$f['name'].' size: '.$f['size']);
|
||||
$out[] = array(
|
||||
'filename' => $f['name'],
|
||||
'size' => (int) $f['size'],
|
||||
'mime' => dol_mimetype($f['name']),
|
||||
'date' => (int) $f['date'],
|
||||
'relpath' => str_replace(DOL_DATA_ROOT.'/', '', $f['fullname']),
|
||||
);
|
||||
|
||||
if (is_dir($upload_dir)) {
|
||||
$allFiles = glob($upload_dir.'/*', GLOB_NOSORT);
|
||||
foreach ($allFiles as $filepath) {
|
||||
if (!is_file($filepath)) continue;
|
||||
$name = basename($filepath);
|
||||
// Ignoriere Meta-Dateien, Previews und Hidden Files
|
||||
if (strpos($name, '.meta') !== false || strpos($name, '_preview') !== false || $name[0] === '.') continue;
|
||||
|
||||
$out[] = array(
|
||||
'filename' => $name,
|
||||
'size' => (int) @filesize($filepath),
|
||||
'mime' => dol_mimetype($name),
|
||||
'date' => (int) @filemtime($filepath),
|
||||
'relpath' => str_replace(DOL_DATA_ROOT.'/', '', $filepath),
|
||||
);
|
||||
}
|
||||
}
|
||||
// Sortiere nach Datum (neuste zuerst)
|
||||
usort($out, function($a, $b) { return $b['date'] <=> $a['date']; });
|
||||
api_ok(array('photos' => $out, 'count' => count($out)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue