- Issue created by @shaesen
- Status changed to Postponed: needs info
11 months ago 6:29pm 26 December 2023 - πΊπΈUnited States davedg629
I'm getting this same error, but only in the Test (staging) and Live environments of a Pantheon hosted site. Here's the full output from the error log:
Message:
Drupal\Core\File\Exception\FileNotExistsException: File 'temporary://import/zip/794c2c1d-c6ff-4e00-b3ce-e26f06b925a3/assets/athletics_images/5.2_planning_0.jpg' could not be copied because it does not exist. in Drupal\Core\File\FileSystem->prepareDestination() (line 462 of /code/web/core/lib/Drupal/Core/File/FileSystem.php).
Backtrace:
#0 /code/web/core/lib/Drupal/Core/File/FileSystem.php(382): Drupal\Core\File\FileSystem->prepareDestination('temporary://imp...', 'public://athlet...', 1)
#1 /code/web/modules/contrib/single_content_sync/src/ContentImporter.php(438): Drupal\Core\File\FileSystem->move('temporary://imp...', 'public://athlet...', 1)
#2 /code/web/modules/contrib/single_content_sync/src/ContentBatchImporter.php(31): Drupal\single_content_sync\ContentImporter->importAssets('temporary://imp...', 'assets/athletic...')
#3 /code/web/core/includes/batch.inc(296): Drupal\single_content_sync\ContentBatchImporter::batchImportAssets('temporary://imp...', 'assets/athletic...', Array)
#4 /code/web/core/includes/batch.inc(138): _batch_process()
#5 /code/web/core/includes/batch.inc(94): _batch_do()
#6 /code/web/core/modules/system/src/Controller/BatchController.php(52): _batch_page(Object(Symfony\Component\HttpFoundation\Request))
#7 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request))
#8 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#9 /code/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#11 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#12 /code/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /code/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /code/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /code/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /code/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /code/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main} - πΊπ¦Ukraine nginex
Could you please ensure that temporary folder is properly configured on stage and live? Do you use external file storage?
- πΊπΈUnited States davedg629
Ok, so I believe the issue is explained in Pantheon's doc here: https://docs.pantheon.io/symlinks-assumed-write-access
Essentially, the module is trying to write files to directories outside of the standard Drupal files directory (sites/default/files). For Pantheon hosted sites, Drupal does not have write access to any directories except sites/default/files.
Would it be possible to change the directories this module writes files to so any files are written to a directory within sites/default/files?
- πΊπ¦Ukraine nginex
I'm currently working on a solution where creating files will not be needed.
It will use StreamedResponse instead of downloading file.
For now I think I can provide a patch where the file schema can be configured. e.g. temporary, public, private and etc
- πΊπΈUnited States davedg629
A patch would be great. Thanks for your responsiveness!
Hi all, I'm encountering the same issue on an Acquia hosted site, only on my production environment. I'm not totally sure whether my problem is the same/similar as what's mentioned above about Pantheon sites, but did find this snippet on the following page:
https://docs.acquia.com/acquia-cloud-platform/manage-apps/files/temporary
"Drupal modules that write to temporary directories may require additional configuration to function properly in environments with multiple infrastructures, such as production environments for Cloud Platform Enterprise and Cloud Platform Site Factory."It then goes on to list modules that are incompatible with Cloud Platform, but Single Content Sync is not mentioned. I'm thinking the patch mentioned above would help me as well.
Thank you so much for this wonderful module -- my team has been wanting this exact functionality for a while and it's been quite useful already on our non-production environments!
- πΊπΈUnited States davedg629
I've done some more research on this and as far as Pantheon hosted sites go, I'm almost positive the issue is described in their documentation here under "Persistent Temporary Path Workaround": https://docs.pantheon.io/guides/filesystem/tmp#persistent-temporary-path...
That said, I can't get the workaround to work. Here's what I've done:
1. Created a patch (attached) that allows you to set the root of the temporary directory in settings.php.
2. Added the following to settings.php to override the temp directory that the module uses: $config['single_content_sync']['temp_root'] = 'private://tmp/';
3. I've created the directory at sites/default/files/private/tmp. I also created sites/default/files/private/tmp/export/zip and sites/default/files/private/tmp/import/zip.When I try to import a .zip file, I get this error: The content file in YAML format could not be found.
Not sure why this error is happening. Either the override in settings.php is not the correct path or there is something else the module is doing that I don't understand.
If anyone has any ideas, please let me know. Otherwise I'll be hoping for a new version of the module that doesn't require the creation of files.