Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Uncache folders, get drive service, empty trash #30

Merged
merged 3 commits into from
Jul 19, 2021

Conversation

erikn69
Copy link
Contributor

@erikn69 erikn69 commented Jul 16, 2021

  • getService() added
    Closes Access to Google_Service_Drive property #27, useful in laravel's facade because $service creation is in a ServiceProvider,
    example Storage::disk('google')->getDriver()->getAdapter()->getService()

  • emptyTrash(array $params = []) added
    Closes Delete forever ? #28, bridge to Google_Service_Drive's emptyTrash(for laravel),
    example Storage::disk('google')->getDriver()->getAdapter()->emptyTrash()

    the issue is the storage become full before a month

  • uncacheFolder($path) added
    Closes Error while creating folder after deleting it from gdrive #29, useful on concurrent laravel's jobs, also it can be used like a workaround for avoid duplicity forcing to take first folder always(performance cost, but on queued jobs maybe doesn't matter, can be added something like this for avoid duplicity always?)

    Unfortunately Google Drive allows users to create files and folders with same (displayed) names

    Example for #29 :

$disk=\Storage::disk('google');    
$disk->createDir('test/testa'); //create dir, gets id to cache if it's already exists
//manually delete o permanently destroy on drive without adapter, 
//also maybe another concurrent thread could create a directory with the same name first, now this is a duplicate
$dir=$disk->getDriver()->getAdapter()->getMetadata('test/testa');
$disk->getDriver()->getAdapter()->getService()->files->delete($dir['id']); 
//uncache
$disk->getDriver()->getAdapter()->uncacheFolder('test/testa'); 
//refresh folder id and put file(duplicates stays empty because get first on refresh, if directory was deleted, it creates a new one)
$disk->put('test/testa/file.txt', 'Contents1'); 

still might lead to unexpected problems on concurrent delete, but can it helps to handle duplicates on createDir?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants