-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 for race condition while uploading multiple files with uploadimage plugin #1216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test is failing.
@@ -68,6 +68,8 @@ | |||
|
|||
this.responseData = {}; | |||
}; | |||
|
|||
// sinon.spy( CKEDITOR.fileTools.fileLoader.prototype, 'upload' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could probably be deleted safely.
wait(); | ||
}, | ||
|
||
'test uploads generate unique names (#1213)': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test is always failing:
TypeError: Attempted to wrap create which is already wrapped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, TBH don't know how I missed that.
// Returns an unique image file name. | ||
function getUniqueImageFileName( type ) { | ||
var date = new Date(), | ||
dateParts = [ date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds() ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we use simply timestamp here, returned from Date.now()
/Date.prototype.getTime()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to give it some human readability, at the same time not making the name too long. So we'd like to stick to YYYYmmddhhmmss schema.
…files having the same name.
…imes. Also removed commented code.
What is the purpose of this pull request?
Bug fix
This PR contains
What changes did you make?
This issue is more of a workaround, as the problem is actually on a CKFinder side, but we can't quickly fix it there, so we'll patch client side first.
Now, the problem was that CKFinder had a problem handling multiple files with the same name loaded at once, so we'll generate unique file name for each one. It's a bit dirty, and optimistic, but should do the trick for now.
Manaul Tests
To be honest I had no good idea how to make a good manual test here. To make it reliable I have set a CKFinder 3 instance on my dev workstation, and added configuration to
config.js
:By adding:
And adding
'uploadimage'
to the plugin list.Closes #1213.