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

[PB-3097, PB-2977] Filter files in trash - Delete files from deleted folders #422

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

evillalba94
Copy link
Contributor

Ticket

Updates

  • Fixed the files to be displayed in the Recents section
  • Improved the handling of files in the Trash section

@evillalba94 evillalba94 added the enhancement New feature or request label Nov 5, 2024
@evillalba94 evillalba94 self-assigned this Nov 5, 2024
@evillalba94 evillalba94 requested review from apsantiso and removed request for apsantiso November 5, 2024 18:17
Comment on lines 817 to 832
const files = await this.fileUsecases.getFilesByFolderUuid(
folder.uuid,
FileStatus.TRASHED,
);
const fileIds = files.map((f) => f.fileId);
const updateFileData: Partial<File> = {
deleted: false,
deletedAt: null,
status: FileStatus.EXISTS,
};

await this.fileUsecases.updateManyByFileIdAndUserId(
fileIds,
user.id,
updateFileData,
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is better to make a query that updates all the files inside that folder instead of fetching and updating them. We have no limits for files inside a folder, so if an user has 10k files in a folder, those are 10k files you're fetching/looping through here.

@@ -36,6 +36,7 @@ import { WorkspaceAttributes } from '../workspaces/attributes/workspace.attribut
import { Folder } from '../folder/folder.domain';
import { getPathFileData } from '../../lib/path';
import { isStringEmpty } from '../../lib/validators';
import { Op } from 'sequelize';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you try to use this in the repository? You can find the reason in this comment: #428 (comment)

@evillalba94 evillalba94 changed the title [PB-3097] Filter files in trash - Delete files from deleted folders [PB-3097, PB-2977] Filter files in trash - Delete files from deleted folders Nov 22, 2024
@sg-gs
Copy link
Member

sg-gs commented Dec 16, 2024

This PR it's non-sense. The issue with this thing is related to the background deletion system we have on Drive. It is deleted eventually. If you want to filter Recents and Trash without still-not-deleted items, you need to do a recursive query when listing those items, to check if any of their folder parents removed field is true @apsantiso @evillalba94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready-for-preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants