Skip to content

Commit

Permalink
fix(files_sharing): Resolve race condition blocking link share requests
Browse files Browse the repository at this point in the history
Fixed a race condition in the frontend that prevented share link creation requests
from being sent to the backend. Instead of communicating with the server,
the share links were incorrectly added to the frontend list, and a new menu
to create another link appeared.

This fix ensures the correct sequence of actions, allowing share links to be
properly created and synchronized with the backend.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Dec 5, 2024
1 parent 66e09eb commit 8b68f3d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export default {
copySuccess: true,
copied: false,
defaultExpirationDateEnabled: false,
shareReviewComplete: false,

// Are we waiting for password/expiration date
pending: false,
Expand Down Expand Up @@ -492,7 +493,10 @@ export default {
},

shareRequiresReview() {
return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
if (this.shareReviewComplete) {
return false
}
return (this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault) && !this.isPendingShare
},

sharePolicyHasRequiredProperties() {
Expand Down Expand Up @@ -596,8 +600,8 @@ export default {
},
},
mounted() {
this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date
if (this.share) {
this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date
this.share.expireDate = this.defaultExpirationDateEnabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
}
},
Expand Down Expand Up @@ -629,8 +633,7 @@ export default {
if ((this.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) || this.shareRequiresReview) {
this.pending = true
this.shareCreationComplete = false

this.logger.info('Share policy requires mandated properties (password)...')
this.logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')

// ELSE, show the pending popovermenu
// if password default or enforced, pre-fill with random one
Expand All @@ -648,6 +651,7 @@ export default {
// freshly created share component
this.open = false
this.pending = false
this.shareReviewComplete = true
component.open = true

// Nothing is enforced, creating share directly
Expand Down Expand Up @@ -678,6 +682,7 @@ export default {
const share = new Share(shareDefaults)
await this.pushNewLinkShare(share)
this.shareCreationComplete = true
this.shareReviewComplete = false
}
},

Expand Down

0 comments on commit 8b68f3d

Please sign in to comment.