10000 fix delete cache file to dbp-master by shimonewman · Pull Request #5699 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix delete cache file to dbp-master #5699

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

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions app/controllers/api/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@
->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));

Expand Down Expand Up @@ -1258,8 +1257,7 @@
->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));

Expand Down Expand Up @@ -1325,11 +1323,6 @@
$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())
Expand Down
3 changes: 1 addition & 2 deletions app/workers/deletes.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ function (Document $document) {
*/
protected function deleteCacheByResource(Document $project, string $resource): void
{
$dbForProject = $this->getProjectDB($project);
$projectId = $project->getId();
$dbForProject = $this->getProjectDB($project);
$document = $dbForProject->findOne('cache', [Query::equal('resource', [$resource])]);

if ($document) {
Expand Down Expand Up @@ -200,7 +200,6 @@ function ($document) use ($cache, $projectId) {
protected function deleteCacheByDate(string $datetime): void
{
$this->deleteForProjectIds(function (Document $project) use ($datetime) {

$projectId = $project->getId();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we remove this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are passing the $project already to $dbForProject = $this->getProjectDB($project);
so we use $project->getId() instad of $projectId

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But $projectId was equal to $project->getId()

$dbForProject = $this->getProjectDB($project);
$cache = new Cache(
Expand Down
0