-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
MWS: fix editing attachment tiddlers #8455
MWS: fix editing attachment tiddlers #8455
Conversation
Confirmed: webplusai has already signed the Contributor License Agreement (see contributing.md) |
Confirmed: webplusai has already signed the Contributor License Agreement (see contributing.md) |
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.
Thank you @webplusai for the speedy response. It's great to see that you've been able to identify a fix so swiftly with unfamiliar code.
I have only conducted a brief review so far as I am away from my desk. I will try it out properly when I am back.
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
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.
Thanks @webplusai much appreciated
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
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.
Hi @webplusai thank you, this is looking good. My concerns now are around the edge cases.
Have you seen the test framework in $:/plugins/tiddlywiki/multiwikiserver/commands/mws-test-server.js? I think we need to look at introducing some tests for the attachment handling logic. I would hope it could be done relatively easily if we could figure out a convenient way to bring down the attachment size limit so that the tests can work with attachments of 10s of bytes.
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js
Outdated
Show resolved
Hide resolved
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.
Hi @webplusai this is looking very good. The new tests are very clear and much appreciated.
There are a couple of minor points but otherwise I think this is ready to merge
.gitignore
Outdated
@@ -10,3 +10,6 @@ store/ | |||
/playwright-report/ | |||
/playwright/.cache/ | |||
$__StoryList.tid | |||
/editions/test/test-store/* | |||
/coverage | |||
/.nyc_output |
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.
I think the last two entries are no longer required.
Tests attachments. | ||
|
||
\*/ | ||
var fs = require('fs'); |
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.
I apologise in advance, but an aspect of our coding style that is unorthodox is that we prefer strings to use double quotes
/*\ | ||
title: test-attachment.js | ||
type: application/javascript | ||
tags: [[$:/tags/test-spec]] |
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.
These tests should reside within the multiwikiserver plugin, and the tiddlywiki.info for the editions/test
edition should be modified to include the multiwikiserver plugin. (This is the approach that the geospatial plugin uses for its tests).
created: $tw.utils.stringifyDate(new Date()), | ||
modified: $tw.utils.stringifyDate(new Date()), | ||
contentHash: contentHash, | ||
filename: dataFilename, | ||
type: options.type | ||
type: options.type, |
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.
There's an extraneous comma at the end of this line
},null,4)); | ||
return contentHash; | ||
}; | ||
|
||
/* | ||
Adopts an attachment file into the store | ||
*/ | ||
AttachmentStore.prototype.adoptAttachment = function(incomingFilepath,type,hash) { | ||
AttachmentStore.prototype.adoptAttachment = function(incomingFilepath,type,hash,canonicalUri) { |
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.
I think we should consistently use _canonical_uri
as the variable name
|
||
let shouldProcessAttachment = tiddlerFields.text && tiddlerFields.text.length <= attachmentSizeLimit; | ||
|
||
if (existing_attachment_blob) { |
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.
Another coding style weirdness is that we don't include whitespace between if
and the parenthesis.
@pmario may be able to advise on linter settings that can help with TW coding styles
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.
Thank you again for you patience @webplusai. This is excellent quality of work.
There's a couple of minor points below, but otherwise this is ready to merge.
package-lock.json
Outdated
"version": "7.22.20", | ||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", | ||
"integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", | ||
"version": "7.24.7", |
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.
I don't think these changes to package-lock.json are needed anymore.
package.json
Outdated
"test": "node ./tiddlywiki.js ./editions/test --verbose --version --build index && node ./tiddlywiki ./editions/multiwikiserver/ --build load-mws-demo-data --mws-listen --mws-test-server http://127.0.0.1:8080/ --quit", | ||
"start": "node ./tiddlywiki.js ./editions/multiwikiserver --mws-load-plugin-bags --build load-mws-demo-data --mws-listen", | ||
"build:test-edition": "node ./tiddlywiki.js ./editions/test --verbose --version --build index", | ||
"build:multiwikiserver-edition": "node ./tiddlywiki.js ./editions/multiwikiserver/ --build load-mws-demo-data --mws-listen --mws-test-server http://127.0.0.1:8080/ --quit", |
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.
It looks like this should perhaps be test:multiwikiserver-edition
?
@@ -170,7 +170,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) { | |||
* Default number of milliseconds Jasmine will wait for an asynchronous spec to complete. | |||
* @name jasmine.DEFAULT_TIMEOUT_INTERVAL | |||
*/ | |||
j$.DEFAULT_TIMEOUT_INTERVAL = 5000; | |||
j$.DEFAULT_TIMEOUT_INTERVAL = 30000; |
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.
Files within the plugins/tiddlywiki/jasmine/files
directory are taken directly from the Jasmine release. Any changes here will be overwritten the next time Jasmine is upgraded. If the increased timeout is necessary we should explore whether it can be configured in the TiddlyWIki JS wrappers
Thank you @webplusai for your patience, and congratulations on landing a significant PR. |
3287dce
into
TiddlyWiki:multi-wiki-support
Hi @webplusai it turns out that there is a small problem with the tests – they fail if the directory |
Issue: #8446
Each time the image was broken on the webpage while following the reproduction steps. It was as a result of the attachment_blob value being set to null when the tiddler was saved.