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-1617]: fix/ select NOT deleted files when trying to move any file #424

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

apsantiso
Copy link
Collaborator

@apsantiso apsantiso commented Feb 15, 2024

Files with "deleted" status should no be moved nor interacted with.

This endpoint is used to move files out of trash and between folders, it was ignoring if the file is deleted, so it is able to mark "deleted" files as "exists" again.

Then when it reaches this part:

    if (!file) { // File was found despite STATUS = DELETED so this if is bypassed.
      throw Error('File not found');
    }
    const folderSource = await Model.folder.findOne({ where: { id: file.folder_id, user_id: user.id } });
    const folderTarget = await Model.folder.findOne({ where: { id: destination, user_id: user.id } });
    if (!folderSource || !folderTarget) {
      throw Error('Folder not found');
    }
    const originalName = App.services.Crypt.decryptName(file.name, file.folder_id);
    const destinationName = App.services.Crypt.encryptName(originalName, destination);
    const exists = await Model.file.findOne({
      where: {
        name: { [Op.eq]: destinationName },
        folder_id: { [Op.eq]: destination },
        type: { [Op.eq]: file.type },
        fileId: { [Op.ne]: fileId },
        status: { [Op.eq]: 'EXISTS' }, // Where the real problem is .
      },
    });

@apsantiso apsantiso added the bug Something isn't working label Feb 15, 2024
Copy link

src/app/services/files.js Show resolved Hide resolved
@sg-gs sg-gs merged commit 24116fe into master Feb 15, 2024
6 of 10 checks passed
@sg-gs sg-gs deleted the fix/prevent-move-files-if-status-deleted branch February 15, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants