Comments (4)
@erikn69 ok so I checked the production version and that's v2.2.0
so I downgraded locally and the file not found issue I am having was resolved, however, I then did get the Properties can not be manipulated when useHasDir
issue so I manually applied your fixed to the vendor files for now and included a if (!Storage::disk('google')->fileExists($fileId)) continue;
in my code and it runs successfully. It looks like all the files are synced perfectly!
Is there anything else I can test to help debug?
from flysystem-google-drive-ext.
Wich laravel version?, package version? php version? give all the info
This has been working fine but now I just can't get things to work
Did you upgrade the package? still almost no info
if you upgrade, test with the previus version
I did try with the next test and everything is working
/**
* @test
*/
public function testing_file_exist()
{
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->write('test/file1.txt', 'contents', new Config());
$adapter->write('test/file2.txt', 'contents', new Config());
$adapter->write('test/file3.txt', 'contents', new Config());
$this->assertEquals(true, $adapter->fileExists('test/file1.txt'));
$this->assertEquals(true, $adapter->fileExists('test/file2.txt'));
$this->assertEquals(true, $adapter->fileExists('test/file3.txt'));
});
}
from flysystem-google-drive-ext.
@erikn69 thanks for responding so quick! Sorry for lack of information, here's a little more:
PHP Version 8.1.3
"name": "masbug/flysystem-google-drive-ext",
"version": "v2.2.1",
"name": "laravel/framework",
"version": "v9.13.0",
The code is currently working in production. Today I created a new branch locally to upgrade to Nova 4 which I did successfully. I have a custom Tool in Nova that can be triggered by admins which basically syncs the Google drive files so I was reimplementing it from a Tool to an Action.
It was giving me a weird PDOException: There is no active transaction
which took me down a huge rabbit hole of trial and error debugging. I eventually noticed that when I was getting the file metadata to store in the DB it was throwing this error, I think, because it couldn't find the file in the first place.
Here is the production code that now no longer seems to work:
<?php
namespace App\Actions\Google;
use Carbon\Carbon;
use App\Models\MarketingMaterial;
use Illuminate\Support\Facades\Cache;
use App\Models\MarketingMaterialFolder;
use Illuminate\Support\Facades\Storage;
use Lorisleiva\Actions\Concerns\AsAction;
use App\Actions\Google\GetMarketingFolderNameFromDisplayNameParts;
use App\Actions\Google\GetMarketingFolderParentIdFromDisplayNameParts;
class SyncFilesAndFoldersFromGoogle
{
use AsAction;
public function handle(string $folderName = '') : void
{
if ($folderName === '') {
$this->clearDatabaseAndCache();
}
foreach (Storage::cloud()->files($folderName) as $fileId) {
$meta = Storage::cloud()->getAdapter()->getMetadata($fileId);
$extra = $meta->extraMetadata();
$parts = explode('/', $extra['display_path']);
$file = MarketingMaterial::create([
'id' => $extra['id'],
'name' => $extra['filename'] . '.' . $extra['extension'],
'filename' => $extra['filename'] . '.' . $extra['extension'],
'extension' => $extra['extension'],
'modified_at' => Carbon::parse($meta['lastModified']),
'mimetype' => $meta['mimeType'],
'size' => $meta['fileSize'],
'description' => '',
'path' => $meta['path'],
'folder_id' => GetMarketingFolderParentIdFromDisplayNameParts::run($parts),
]);
if (!Storage::disk('thumbnails')->exists($file->getThumbnailFilename())) {
DownloadFileThumbnailFromGoogle::run( $file );
}
}
foreach (Storage::cloud()->directories($folderName) as $directoryName) {
// $meta = Storage::cloud()->
$meta = Storage::cloud()->getAdapter()->getMetadata($directoryName)->extraMetadata();
// the new Google Drive implementation returns display names so
// explode it to get it into parts and we'll deal with what we need from there
$parts = explode('/', $meta['display_path']);
MarketingMaterialFolder::create([
'id' => $meta['id'],
'name' => GetMarketingFolderNameFromDisplayNameParts::run($parts),
'path' => $meta['display_path'],
'description' => '',
'folder_id' => GetMarketingFolderParentIdFromDisplayNameParts::run($parts),
]);
SyncFilesAndFoldersFromGoogle::run($directoryName);
}
}
/**
* Clear both the database of MarketingMaterials and MarketingMaterialFolders
* plus get rid of the cache of marketing view data by tags
*
* @return void
*/
private function clearDatabaseAndCache() : void
{
// clear out all existing files and folders
MarketingMaterial::truncate();
MarketingMaterialFolder::truncate();
// clear marketing folder view cache data
Cache::tags('marketing-folder-data')->flush();
}
}
This code currently works in Production but now locally it will sync the first file, but nothing else. I've tried adding a "if fileExists" check and then if it doesn't, just skip that file and continue - this stops the odd 'no transaction' error but nothing syncs down apart from the first file.
After Googling further, I decided to create a fresh Laravel install today, install the package and create the simple test in the original post which still shows it not finding the file after a subsequent request.
I a fully aware I am probably doing something stupid, but I just can't see it :(
from flysystem-google-drive-ext.
test with the previus version
from flysystem-google-drive-ext.
Related Issues (20)
- creating a new folder in my drive HOT 2
- Backup failed because: Unable to write file at location: HOT 11
- Invalid value at 'payload' (Map) ? HOT 6
- Error in masbug because upgrade system Google API HOT 5
- Duplicate root directories created when instantiating the adapter HOT 3
- 401 Request had invalid authentication credentials (laravel jobs) HOT 4
- Problem with spatie laravel backup - League\Flysystem\UnableToReadFile HOT 8
- Don't list files and Directories in shared folder HOT 1
- Laravel 10 support HOT 2
- Can't display paths, just IDs HOT 1
- How to move app to live HOT 1
- Argument #1 ($value) must be of type Countable|array, null given in GoogleDriveAdapter.php:1037 HOT 3
- Fails to report delete error
- Moving folders will fall into the trash HOT 3
- Allowed memory size issue HOT 1
- create,delete,rename folder,get folder listing and data using folder id instead of name ,to remove duplicacy of same folder name HOT 2
- Rename Directory using laravel HOT 5
- useDisplayPaths is false, but return original filename HOT 4
- On live Server, google drive backup is giving error! HOT 1
- cannot list directory shortcuts HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flysystem-google-drive-ext.