-
Notifications
You must be signed in to change notification settings - Fork 48
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
Register application/x-kdbx the right way #124
Conversation
- Change x-application/kdbx to application/x-kdbx (as in viewer.js) - Fix call to updateFilecache (extension is requested not a pattern) - Inject IMimeTypeLoader via DI Signed-off-by: Daniel Kesselberg <[email protected]>
- Fix call to updateFilecache (extension is requested not a pattern) - Inject IMimeTypeLoader via DI Signed-off-by: Daniel Kesselberg <[email protected]>
Signed-off-by: Daniel Kesselberg <[email protected]>
I'm not 100% sure about this change. It should not be necessary to call getAllMappings to register a new mime type. Probably a definition with config/mimetypemapping.json will overwrite this definition later. App initialization should be cheap. Expensive jobs like getAllMappings are bad. Signed-off-by: Daniel Kesselberg <[email protected]>
public function run(IOutput $output) { | ||
// And update the filecache for it. | ||
$mimetypeId = $this->mimeTypeLoader->getId('application/x-kdbx'); | ||
$this->mimeTypeLoader->updateFilecache('kdbx', $mimetypeId); |
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.
updateFilecache
is looking for a extension. A pattern like %.kdbx
do not work.
|
||
// And update the filecache for it. | ||
$mimetypeId = $mimeTypeLoader->getId('x-application/kdbx'); |
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.
nextcloud-keeweb/keeweb/js/viewer.js
Line 21 in 380e78f
mime: 'application/x-kdbx', |
Do not work because they mimetype is created as x-application/kdbx
over here.
can confirm this is working (tested in newly setup nc-docker with nc 17). this should definitly get merged |
New files or edited files are not detected correctly.
As the mimetypes are correctly in the database it seems that there is something wrong with detecting the mimetype correctly. Could you look into that? |
Filesystem loads the app also for request via dav. This is required to assign the mime type. Signed-off-by: Daniel Kesselberg <[email protected]>
- Register mime type before app initialization - Skip the app initialization for dav requests Signed-off-by: Daniel Kesselberg <[email protected]>
Thanks @maurerle 👍 Make sense to me. Keeweb app is not loaded for dav requests and therefore the mime type ( |
$mimeTypeDetector = \OC::$server->getMimeTypeDetector(); | ||
$mimeTypeDetector->registerType('kdbx', 'application/x-kdbx', 'application/x-kdbx'); | ||
|
||
if (\OC::$REQUESTEDAPP === 'dav') { |
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.
cc @rullzer @nickvergessen does that make sense? ;) For a dav request we need to announce the mime type to nextcloud. The app itself is not required. I'm trying to save some resources by skipping the app initialization.
This works! 😄 So when doing it through |
Loading the app tells nextcloud that files with nextcloud-keeweb/keeweb/appinfo/app.php Lines 17 to 23 in e0ee3d9
Yes. A entry in |
It's required to call getAllMappings before registerType otherwise the default mappings are not loaded. Signed-off-by: Daniel Kesselberg <[email protected]>
Nextcloud 18 will contain |
So with this we can drop the instructions from the readme right? Sorry for not responding earlier here. To be honest I don't know enough about Nextcloud to fully verify this is sane, but it sounds like you know what you're doing here. So I'm sure it won't be any more broken than it is right now, so I'll merge this for now. Btw if you're interested in (co-) maintaining... ;) |
Thanks for merging 👍
I hope 🙈
Sorry 😞 I don't have enough time for co-maintaining a app. Luckily there seems to be some progress with the documentation for developers so it should be easier to keep up with the latest changes and better instructions how to migrate code. I think that most of the issues reports here should be solved with this PR. That will hopefully reduce your workload. Ping me if you're stuck somehow. I'll try to have a look. |
Hi @jhass,
Thanks for your app 👍 Some people at nextcloud/server (e.g. nextcloud/server#17217) and also over here are reporting issues.
*.kdbx
files are not opened with the app 😞This pull request should fix most of these issues and also make the manual changes to
mimetypemapping.json
superfluous (at least on my setup).I'm not a heavy user of keeweb. We probably need some testers ;)