1
0
Fork 0
mirror of synced 2024-07-05 14:40:42 +12:00

cache deletion bug fix

This commit is contained in:
shimon 2023-06-13 15:03:22 +03:00
parent 7ec4b2171c
commit a4e055e21b
2 changed files with 5 additions and 13 deletions

View file

@ -359,8 +359,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
->inject('mode')
->inject('deviceFiles')
->inject('deviceLocal')
->inject('deletes')
->action(function (string $bucketId, string $fileId, mixed $file, ?array $permissions, Request $request, Response $response, Database $dbForProject, Document $user, Event $events, string $mode, Device $deviceFiles, Device $deviceLocal, Delete $deletes) {
->action(function (string $bucketId, string $fileId, mixed $file, ?array $permissions, Request $request, Response $response, Database $dbForProject, Document $user, Event $events, string $mode, Device $deviceFiles, Device $deviceLocal) {
$bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId));
@ -1258,8 +1257,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId')
->inject('user')
->inject('mode')
->inject('events')
->inject('deletes')
->action(function (string $bucketId, string $fileId, ?array $permissions, Response $response, Database $dbForProject, Document $user, string $mode, Event $events, Delete $deletes) {
->action(function (string $bucketId, string $fileId, ?array $permissions, Response $response, Database $dbForProject, Document $user, string $mode, Event $events) {
$bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId));
@ -1325,11 +1323,6 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId')
$file = Authorization::skip(fn() => $dbForProject->updateDocument('bucket_' . $bucket->getInternalId(), $fileId, $file));
}
$deletes
->setType(DELETE_TYPE_CACHE_BY_RESOURCE)
->setResource('file/' . $file->getId())
;
$events
->setParam('bucketId', $bucket->getId())
->setParam('fileId', $file->getId())

View file

@ -168,8 +168,8 @@ class DeletesV1 extends Worker
*/
protected function deleteCacheByResource(Document $project, string $resource): void
{
$dbForProject = $this->getProjectDB($project);
$projectId = $project->getId();
$dbForProject = $this->getProjectDB($projectId);
$document = $dbForProject->findOne('cache', [Query::equal('resource', [$resource])]);
if ($document) {
@ -199,10 +199,9 @@ class DeletesV1 extends Worker
*/
protected function deleteCacheByDate(string $datetime): void
{
$this->deleteForProjectIds(function (Document $project) use ($datetime) {
$this->deleteForProjectIds(function (Document $projectId) use ($datetime) {
$projectId = $project->getId();
$dbForProject = $this->getProjectDB($project);
$dbForProject = $this->getProjectDB($projectId);
$cache = new Cache(
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId)
);