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

fix(files_sharing): Resolve race condition blocking link share requests #49442

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
24 changes: 20 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,8 @@
copySuccess: true,
copied: false,
defaultExpirationDateEnabled: false,
shareReviewComplete: false,
calls: 0,

// Are we waiting for password/expiration date
pending: false,
Expand Down Expand Up @@ -472,7 +474,7 @@
* @return {boolean}
*/
pendingDataIsMissing() {
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate || this.shareRequiresReview
},
pendingPassword() {
return this.config.enableLinkPasswordByDefault && this.isPendingShare
Expand All @@ -492,6 +494,10 @@
},

shareRequiresReview() {
console.log("share requires review according to this.shareReviewComplete", this.shareReviewComplete)

Check failure on line 497 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected console statement

Check failure on line 497 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Strings must use singlequote
if (this.shareReviewComplete) {
return false
}
return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
},

Expand Down Expand Up @@ -596,8 +602,8 @@
},
},
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 @@ -627,10 +633,15 @@
// A share would require a review for example is default expiration date is set but not enforced, this allows
// the user to review the share and remove the expiration date if they don't want it
if ((this.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) || this.shareRequiresReview) {
console.log("Share requires review", {

Check failure on line 636 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected console statement

Check failure on line 636 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Strings must use singlequote
sharePolicyHasRequiredProperties: this.sharePolicyHasRequiredProperties,
requiredPropertiesMissing: this.requiredPropertiesMissing,
shareRequiresReview: this.shareRequiresReview
})
this.pending = true
this.shareCreationComplete = false

this.logger.info('Share policy requires mandated properties (password)...')
//debugger

Check failure on line 643 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected space or tab after '//' in comment
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,13 +659,17 @@
// freshly created share component
this.open = false
this.pending = false
this.shareReviewComplete = true
component.open = true

// Nothing is enforced, creating share directly
} else {

console.log("Gets here to non review share creation")

Check failure on line 668 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected console statement

Check failure on line 668 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Strings must use singlequote

// if a share already exists, pushing it
if (this.share && !this.share.id) {
console.log("Does not get blocked by share.id")

Check failure on line 672 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected console statement

Check failure on line 672 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Strings must use singlequote
// if the share is valid, create it on the server
if (this.checkShare(this.share)) {
try {
Expand All @@ -678,6 +693,7 @@
const share = new Share(shareDefaults)
await this.pushNewLinkShare(share)
this.shareCreationComplete = true
this.shareReviewComplete = false
}
},

Expand Down
Loading