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-1513]: Fix/loop-when-delete-files #442

Merged
merged 3 commits into from
Feb 9, 2024

Conversation

miguelsw
Copy link
Contributor

@miguelsw miguelsw commented Jan 18, 2024

Context:

  • Emited events from node-win to delete files, It is verified that there are no folders pending deletion in the queue so a loop was triggered.

Update:

  • Retry mechanism to avoid error on deleting folders
  • Remove folders from queue when a folder father is received
  • Remove always files from queue if its folder was added in folder queue
  • Always remove folder from queue when is executed to delete from remote
  • We should create the tree of folder with error during deleting.

@miguelsw miguelsw self-assigned this Jan 18, 2024
@miguelsw miguelsw requested a review from JoanVicens January 18, 2024 17:02
run(contentId: File['contentsId'], folderContentId: Folder['uuid']): boolean {
const file = this.repository.searchByPartial({ contentsId: contentId });
const folder = this.folderFinder.findFromId(file?.folderId);
const [_, folderUuid] = folder.placeholderId.split(':');
Copy link
Contributor

Choose a reason for hiding this comment

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

folder has the UUID stored, so you can simply do folder.uuid


run(contentId: File['contentsId'], folderContentId: Folder['uuid']): boolean {
const file = this.repository.searchByPartial({ contentsId: contentId });
const folder = this.folderFinder.findFromId(file?.folderId);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid having findFromId with the id optional. If there is no ID we already know that it will fail to find it. So I would add a guard clause, this way if the file is not found, then the error thrown is from the file not being in the repo and not that a folder

}

private async executeFn(item: string) {
this.queue.delete(item);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be the other way around, first execute the function and delete it from the queue? I'm worried that if the deletion takes too long it can allow to delete files that does not need to be deleted

Copy link
Contributor

@JoanVicens JoanVicens left a comment

Choose a reason for hiding this comment

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

Awesome work, I only have a few nitpicks

@miguelsw miguelsw requested a review from JoanVicens January 23, 2024 00:29
@miguelsw miguelsw changed the base branch from master-erb to monitoring-polling-system February 9, 2024 03:55
@miguelsw miguelsw force-pushed the fix/lopp-deleting-files branch from 8e2b062 to e5d858a Compare February 9, 2024 04:19
Copy link

sonarqubecloud bot commented Feb 9, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@miguelsw miguelsw merged commit 09c59e8 into monitoring-polling-system Feb 9, 2024
1 of 2 checks passed
@sg-gs sg-gs deleted the fix/lopp-deleting-files branch May 22, 2024 14:16
@sg-gs sg-gs restored the fix/lopp-deleting-files branch May 22, 2024 14:16
@sg-gs sg-gs deleted the fix/lopp-deleting-files branch May 22, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants