mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
PHRAS-3519_upload-tmp-then-move
implement atomic (?) "tmp+move" method on uploaded file add traces of document filesize
This commit is contained in:
@@ -1700,12 +1700,31 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
|
||||
$pathhd = $filesystem->generateDataboxDocumentBasePath($databox);
|
||||
$newname = $filesystem->generateDocumentFilename($record, $file->getFile());
|
||||
$newname_tmp = $newname.".tmp";
|
||||
|
||||
clearstatcache(true, $file->getFile()->getRealPath());
|
||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
||||
sprintf("copy \"%s\" to \"%s\"", $file->getFile()->getRealPath(), $pathhd . $newname)
|
||||
sprintf("copying \"%s\" (size=%s) to \"%s\"", $file->getFile()->getRealPath(), filesize($file->getFile()->getRealPath()), $pathhd . $newname_tmp)
|
||||
), FILE_APPEND | LOCK_EX);
|
||||
|
||||
$filesystem->copy($file->getFile()->getRealPath(), $pathhd . $newname_tmp);
|
||||
|
||||
clearstatcache(true, $pathhd . $newname_tmp);
|
||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
||||
sprintf("copied \"%s\" to \"%s\" (size=%s)", $file->getFile()->getRealPath(), $pathhd . $newname_tmp, filesize($pathhd . $newname_tmp))
|
||||
), FILE_APPEND | LOCK_EX);
|
||||
|
||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
||||
sprintf("moving \"%s\" (size=%s) to \"%s\"", $pathhd . $newname_tmp, filesize($pathhd . $newname_tmp), $pathhd . $newname)
|
||||
), FILE_APPEND | LOCK_EX);
|
||||
|
||||
$filesystem->rename($pathhd . $newname_tmp, $pathhd . $newname);
|
||||
|
||||
clearstatcache(true, $pathhd . $newname);
|
||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
||||
sprintf("moved \"%s\"to \"%s\" (size=%s) ", $pathhd . $newname_tmp, $pathhd . $newname, filesize($pathhd . $newname))
|
||||
), FILE_APPEND | LOCK_EX);
|
||||
|
||||
$filesystem->copy($file->getFile()->getRealPath(), $pathhd . $newname);
|
||||
|
||||
$media = $app->getMediaFromUri($pathhd . $newname);
|
||||
media_subdef::create($app, $record, 'document', $media);
|
||||
|
Reference in New Issue
Block a user