Fixed XFMG - Rebuild Thumbnails File Not Found Exception

MRaburn

Active member
Getting this error after upgrading from 1.x to 2.x and we were attempting to rebuild the watermarks and get the error below. I can see in the internal/xfmg folder there is no directory named /10/. Only 8,9,11,12,13. This structure is different on my 1.x install so not sure where what broke when or if it is a bug. Thanks for any help, we are stuck on the cron rebuild at this point and cant proceed.

UPDATE: Actually this was the Update Watermark command, the rebuild items and thumbs seemed to be ok. I wonder if I lost some originals during the upgrade or during the regenerate items?

Code:
League\Flysystem\FileNotFoundException: File not found at path: xfmg/original/10/10553-d2d262bd32d48c27b1a8a518b2d101c1.data in src/vendor/league/flysystem/src/Filesystem.php at line 385
League\Flysystem\Filesystem->assertPresent() in src/vendor/league/flysystem/src/Filesystem.php at line 193
League\Flysystem\Filesystem->readStream()
call_user_func_array() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 431
League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 395
League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 154
League\Flysystem\EventableFilesystem\EventableFilesystem->readStream()
call_user_func_array() in src/vendor/league/flysystem/src/MountManager.php at line 269
League\Flysystem\MountManager->invokePluginOnFilesystem() in src/vendor/league/flysystem/src/MountManager.php at line 179
League\Flysystem\MountManager->__call() in src/XF/Util/File.php at line 91
XF\Util\File::copyAbstractedPathToTempFile() in src/addons/XFMG/Service/Media/Watermarker.php at line 39
XFMG\Service\Media\Watermarker->watermark() in src/addons/XFMG/Job/UpdateWatermark.php at line 82
XFMG\Job\UpdateWatermark->run() in src/XF/Job/Manager.php at line 241
XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 187
XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 76
XF\Job\Manager->runQueue() in src/XF/Admin/Controller/Tools.php at line 139
XF\Admin\Controller\Tools->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 88
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1889
XF\App->run() in src/XF.php at line 328
XF::runApp() in admin.php at line 13
 
Last edited:
It's worth noting, just because I've seen people do this fairly commonly, that unless you have a specific reason to run the rebuilds or we advise you to, there's absolutely no need to. Especially seeing as any rebuilds that need to be done during upgrade (such as the thumbnails) were effectively already done.

We're unlikely to be able to figure out where the file has gone, now, though if you have a back up of your files I might be able to direct you towards finding that and moving it into the correct place. Actually, if you happen to still have an internal_data/xengallery/originals directory then you may still have the file.

Incidentally, we've seen files go missing in the past but generally it has happened during backup/restore operations or when moving servers and that kind of thing. It could of course have happened due to some sort of past bug or read/write failure during the upgrade but it will likely be impossible to find out exactly what.

If all else fails, we can maybe just update the database so that the media item is no longer recorded as "watermarked" but of course as the image is already watermarked it could end up giving it a double watermark which might not be desirable.
 
As an update...
Not sure why Folder 10 was missing, BUT both Regenerate Media Items and Thumbnails will complete on their own with errors of missing items, but the Regen Watermarks fails/stops when it hits a missing file.
 
@Chris D,

One of my admins had restarted the Rebuild and this is how I had found it.

I had moved the installation to a new server so I may be missing some files and will attempt to find and move over if I can.

Thanks for your input and advice. I guess maybe just the Watermark function when it hits an error just stops and does not continue, unlike the first two on rebuild.

MIke
 
I've added some code to prevent the error.

If you'd like to implement that now edit the file src/addons/XFMG/Service/Media/Watermarker.php and below:
PHP:
$abstractedPath = $mediaItem->getAbstractedDataPath();
Add:
PHP:
if (!$this->app->fs()->has($abstractedPath))
{
   return false;
}
 
I applied the patch but still get the same error Chris. Function looks like:

Code:
protected function copyToOriginalPathIfNeeded()
    {
        $mediaItem = $this->mediaItem;
        $abstractedPath = $mediaItem->getAbstractedDataPath();
        if (!$this->app->fs()->has($abstractedPath))
            {
               return false;
            }
        $abstractedOriginalPath = $mediaItem->getOriginalAbstractedDataPath();

        if ($this->app->fs()->has($abstractedOriginalPath))
        {
            return;
        }

        $tempFile = File::copyAbstractedPathToTempFile($abstractedPath);
        File::copyFileToAbstractedPath($tempFile, $abstractedOriginalPath);
    }
 
Top Bottom