Remove temporary files once they're in the analysis queue following an upload
This commit is contained in:
parent
f4f4de1b34
commit
24f2155a35
@ -317,6 +317,8 @@ class PhotoController extends Controller
|
||||
Log::error('Image upload failed.', ['error' => $photoFile->getError(), 'reason' => $photoFile->getErrorMessage()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($request->has('photo_id'))
|
||||
{
|
||||
@ -376,6 +378,11 @@ class PhotoController extends Controller
|
||||
|
||||
$isSuccessful = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@unlink($photoFile->getRealPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->isXmlHttpRequest())
|
||||
@ -422,6 +429,8 @@ class PhotoController extends Controller
|
||||
$temporaryFolder = sprintf('%s/%s', sys_get_temp_dir(), MiscHelper::randomString());
|
||||
@mkdir($temporaryFolder);
|
||||
|
||||
try
|
||||
{
|
||||
$queueStorage = AnalysisQueueHelper::getStorageQueueSource();
|
||||
|
||||
$mimeType = strtolower($archiveFile->getMimeType());
|
||||
@ -450,7 +459,7 @@ class PhotoController extends Controller
|
||||
{
|
||||
if ($fileInfo->getFilename() == '__MACOSX' || substr($fileInfo->getFilename(), 0, 1) == '.')
|
||||
{
|
||||
@rmdir($fileInfo->getPathname());
|
||||
@rmdir($fileInfo->getRealPath());
|
||||
}
|
||||
|
||||
continue;
|
||||
@ -459,19 +468,19 @@ class PhotoController extends Controller
|
||||
if (substr($fileInfo->getFilename(), 0, 1) == '.')
|
||||
{
|
||||
// Temporary/hidden file - skip
|
||||
@unlink($fileInfo->getPathname());
|
||||
@unlink($fileInfo->getRealPath());
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = getimagesize($fileInfo->getPathname());
|
||||
$result = getimagesize($fileInfo->getRealPath());
|
||||
if ($result === false)
|
||||
{
|
||||
// Not an image file - skip
|
||||
@unlink($fileInfo->getPathname());
|
||||
@unlink($fileInfo->getRealPath());
|
||||
continue;
|
||||
}
|
||||
|
||||
$photoFile = new File($fileInfo->getPathname());
|
||||
$photoFile = new File($fileInfo->getRealPath());
|
||||
$queuedFileName = $queueStorage->uploadToAnalysisQueue($photoFile, $queueUid);
|
||||
|
||||
$photo = new Photo();
|
||||
@ -504,6 +513,13 @@ class PhotoController extends Controller
|
||||
$rabbitmq = new RabbitMQService();
|
||||
$rabbitmq->queueItem($queueItem);
|
||||
}
|
||||
|
||||
@unlink($fileInfo->getRealPath());
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@rmdir($temporaryFolder);
|
||||
}
|
||||
|
||||
return redirect(route('albums.analyse', [
|
||||
|
Loading…
Reference in New Issue
Block a user