Skip to content

Commit 1894862

Browse files
committed
fix(files_sharing): Resolve race condition blocking link share requests
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 <[email protected]>
1 parent bca864d commit 1894862

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ export default {
298298
copySuccess: true,
299299
copied: false,
300300
defaultExpirationDateEnabled: false,
301+
shareReviewComplete: false,
302+
calls: 0,
301303
302304
// Are we waiting for password/expiration date
303305
pending: false,
@@ -472,7 +474,7 @@ export default {
472474
* @return {boolean}
473475
*/
474476
pendingDataIsMissing() {
475-
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate
477+
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate || this.shareRequiresReview
476478
},
477479
pendingPassword() {
478480
return this.config.enableLinkPasswordByDefault && this.isPendingShare
@@ -492,6 +494,10 @@ export default {
492494
},
493495
494496
shareRequiresReview() {
497+
console.debug('Share requires review?', this.shareReviewComplete)
498+
if (this.shareReviewComplete) {
499+
return false
500+
}
495501
return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
496502
},
497503
@@ -596,8 +602,8 @@ export default {
596602
},
597603
},
598604
mounted() {
605+
this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date
599606
if (this.share) {
600-
this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date
601607
this.share.expireDate = this.defaultExpirationDateEnabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
602608
}
603609
},
@@ -627,10 +633,15 @@ export default {
627633
// A share would require a review for example is default expiration date is set but not enforced, this allows
628634
// the user to review the share and remove the expiration date if they don't want it
629635
if ((this.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) || this.shareRequiresReview) {
636+
console.debug('Share requires review', {
637+
sharePolicyHasRequiredProperties: this.sharePolicyHasRequiredProperties,
638+
requiredPropertiesMissing: this.requiredPropertiesMissing,
639+
shareRequiresReview: this.shareRequiresReview
640+
})
630641
this.pending = true
631642
this.shareCreationComplete = false
632-
633-
this.logger.info('Share policy requires mandated properties (password)...')
643+
//debugger
644+
this.logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')
634645
635646
// ELSE, show the pending popovermenu
636647
// if password default or enforced, pre-fill with random one
@@ -648,11 +659,18 @@ export default {
648659
// freshly created share component
649660
this.open = false
650661
this.pending = false
662+
this.shareReviewComplete = true
651663
component.open = true
652664
653665
// Nothing is enforced, creating share directly
654666
} else {
655667
668+
console.debug('Share does not require review', {
669+
sharePolicyHasRequiredProperties: this.sharePolicyHasRequiredProperties,
670+
requiredPropertiesMissing: this.requiredPropertiesMissing,
671+
shareRequiresReview: this.shareRequiresReview
672+
})
673+
656674
// if a share already exists, pushing it
657675
if (this.share && !this.share.id) {
658676
// if the share is valid, create it on the server
@@ -678,6 +696,7 @@ export default {
678696
const share = new Share(shareDefaults)
679697
await this.pushNewLinkShare(share)
680698
this.shareCreationComplete = true
699+
this.shareReviewComplete = false
681700
}
682701
},
683702

0 commit comments

Comments
 (0)