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
Merged
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
51 changes: 28 additions & 23 deletions src/app/services/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
await file.destroy();
};

const UpdateMetadata = (user, fileId, metadata, mnemonic, bucketId, relativePath) => {

Check warning on line 198 in src/app/services/files.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'mnemonic' is defined but never used

Check warning on line 198 in src/app/services/files.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'bucketId' is defined but never used

Check warning on line 198 in src/app/services/files.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'relativePath' is defined but never used

Check warning on line 198 in src/app/services/files.js

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

'mnemonic' is defined but never used

Check warning on line 198 in src/app/services/files.js

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

'bucketId' is defined but never used

Check warning on line 198 in src/app/services/files.js

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

'relativePath' is defined but never used
const newMeta = {};

return async.waterfall([
Expand Down Expand Up @@ -244,14 +244,15 @@
: '';

// Check if there is a file with the same name
Model.file.findOne({
where: {
folder_id: { [Op.eq]: file.folder_id },
name: { [Op.eq]: cryptoFileName },
type: { [Op.eq]: file.type },
status: { [Op.eq]: 'EXISTS' },
},
})
Model.file
.findOne({
where: {
folder_id: { [Op.eq]: file.folder_id },
name: { [Op.eq]: cryptoFileName },
type: { [Op.eq]: file.type },
status: { [Op.eq]: 'EXISTS' },
},
})
.then((duplicateFile) => {
if (duplicateFile) {
return next(new FileWithNameAlreadyExistsError('File with this name exists'));
Expand All @@ -278,7 +279,10 @@
};

const MoveFile = async (user, fileId, destination) => {
const file = await Model.file.findOne({ where: { fileId: { [Op.eq]: fileId } }, userId: user.id });
const file = await Model.file.findOne({
where: { fileId: { [Op.eq]: fileId }, status: { [Op.not]: 'DELETED' } },
sg-gs marked this conversation as resolved.
Show resolved Hide resolved
userId: user.id,
});

if (!file) {
throw Error('File not found');
Expand Down Expand Up @@ -330,19 +334,20 @@

const isFileOfTeamFolder = (fileId) =>
new Promise((resolve, reject) => {
Model.file.findOne({
where: {
file_id: { [Op.eq]: fileId },
},
include: [
{
model: Model.folder,
where: {
id_team: { [Op.ne]: null },
},
Model.file
.findOne({
where: {
file_id: { [Op.eq]: fileId },
},
],
})
include: [
{
model: Model.folder,
where: {
id_team: { [Op.ne]: null },
},
},
],
})
.then((file) => {
if (!file) {
throw Error('File not found on database, please refresh');
Expand Down Expand Up @@ -409,9 +414,9 @@
where: {
userId: user.id,
bucket: {
[Op.ne]: user.backupsBucket
[Op.ne]: user.backupsBucket,
},
status: { [Op.eq]: 'EXISTS' }
status: { [Op.eq]: 'EXISTS' },
},
include: [
{
Expand Down
Loading