rotdrop / nextcloud-app-files-archive

Archive inspection and extraction as Nextcloud app.
Other
9 stars 4 forks source link

Supported archives formats #5

Closed TtuxX closed 1 year ago

TtuxX commented 1 year ago

Hi !

I am wondering if it is possible to add some more archive types to app ?

Thank you very much.

Best regards

rotdrop commented 1 year ago

They should already be supported if wapmorgan/unified-archive supports them. It might be an issue of a missing back-end or bridge driver.

You can check on the console with the CLI tools that come with UnifiedArchive.

Here is the support-matrix:

https://github.com/wapmorgan/UnifiedArchive/blob/master/docs/Drivers.md

rotdrop commented 1 year ago

Ok, at least on my install a ISO-image with .iso extension is simply labelled as application/octett-stream. However this mime-type is used to decide what actio menu entries and side-bar tabs to activate. I suppose it is somehow possible to install new mime-types, but I have to find out.

rotdrop commented 1 year ago

... and then for .rar archives: Nextcloud like to tag them with application/x-rar-compressed while UnifiedArchive expects just application/x-rar. This can easily be cured. However, for the iso images one would have to convince Nextcloud to emit something more specific than just application/octett-stream which simply is the mime-type for "I do not know".

rotdrop commented 1 year ago

The iso thing must be configured inside Nextcloud:

https://docs.nextcloud.com/server/latest/admin_manual/configuration_mimetypes/index.html

The rar thing is fixed by the commit 2ebf23285cc87df5834d4039dfaa767883e8582a

So I suppose this has to be closed with a mixture of "fixed" / "won't fix". But the iso-issue should go to the README.md, so I keep this issue open for the moment in order not to forget it.

rotdrop commented 1 year ago

Added some documentation to the README:

cadaeb1ca363d0aa1e28d2d9a80e9f3be91b817f

Closing this issue for now.

TtuxX commented 1 year ago

The iso thing must be configured inside Nextcloud:

https://docs.nextcloud.com/server/latest/admin_manual/configuration_mimetypes/index.html

Is the line I am supposed to add on "nextcloud/config/mimetypealiases.json" the following one ?

"application/x-iso": "package/x-generic",

rotdrop commented 1 year ago

No, you are supposed to add a file NEXTCLOUD/config/mimetypemapping.json with resp. adding the content:

{
    "iso": ["application/x-iso9660-image"]
}

It is a little bit further to the bottom in the manual. Of course, if you already have such a file, then just have to add the line with the "iso" stuff.

rotdrop commented 1 year ago

This file is used to map extensions to mime-types. Otherwise we just get that application/octett-stream.

TtuxX commented 1 year ago
"iso": ["application/x-iso9660-image"],

Done, I added it to 'NEXTCLOUD/config/mimetypemapping.json'.

I restarted php-fpm and so on but do not see the new Mount menu appear on .iso files. I will wait some time and check again.

... and then for .rar archives: Nextcloud like to tag them with application/x-rar-compressed while UnifiedArchive expects just application/x-rar.

Now the rar files are correctly detected. However, mount does not work on my server, maybe because of a space interpretation issue?:

[index] Error: OCA\FilesArchive\Exceptions\ArchiveCannotOpenException: Unable to open archive file /PATH NAME WITH SPACES AND SO ON.rar (/PATH NAME WITH SPACES AND SO ON.rar) at <>

  1. /usr/local/www/nextcloud/apps/files_archive/lib/Controller/MountController.php line 178 OCA\FilesArchive\Service\ArchiveService->open(OC\Files\Node\File {})
  2. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225 OCA\FilesArchive\Controller\MountController->mount("/XXXX", null, null, null)
  3. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133 OC\AppFramework\Http\Dispatcher->executeController(OCA\FilesArchive ... {}, "mount")
  4. /usr/local/www/nextcloud/lib/private/AppFramework/App.php line 172 OC\AppFramework\Http\Dispatcher->dispatch(OCA\FilesArchive ... {}, "mount")
  5. /usr/local/www/nextcloud/lib/private/Route/Router.php line 298 OC\AppFramework\App::main("OCA\FilesArchi ... r", "mount", OC\AppFramework\ ... {}, [null,"%2FXXXX ... "])
  6. /usr/local/www/nextcloud/lib/base.php line 1030 OC\Route\Router->match("/apps/files_arc ... r")
  7. /usr/local/www/nextcloud/index.php line 36 OC::handleRequest()

POST /apps/files_archive/archive/mount /URL ENCODED PATH NAME WITH SPACES AND SO ON.rar from XXXX.XXXX.XXXX.XXXX by XXXX at 2022-11-10

rotdrop commented 1 year ago

Am 10.11.22 um 18:45 schrieb TtuxX:

|"iso": ["application/x-iso9660-image"], |

Done, I added it to 'NEXTCLOUD/config/mimetypemapping.json'.

I restarted php-fpm and so on but do not see the new Mount menu appear on .iso files. I will wait some time and check again.

Perhaps you also need to run one of these occ-commands:

maintenance:mimetype:update-db Update database mimetypes and update filecache maintenance:mimetype:update-js Update mimetypelist.js

... and then for .rar archives: Nextcloud like to tag them with
|application/x-rar-compressed| while UnifiedArchive expects just
|application/x-rar|.

Now the rar files are correctly detected. However, mount does not work on my server, maybe because of a space interpretation issue?:

I don't think that spaces are the issue. Your other problem was also not a problem with spaces but with dots. But I can try later.

Claus

[index] Error: OCA\FilesArchive\Exceptions\ArchiveCannotOpenException: Unable to open archive file /PATH NAME WITH SPACES AND SO ON.rar (/PATH NAME WITH SPACES AND SO ON.rar) at <>

  1. /usr/local/www/nextcloud/apps/files_archive/lib/Controller/MountController.php line 178 OCA\FilesArchive\Service\ArchiveService->open(OC\Files\Node\File {})
  2. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225 OCA\FilesArchive\Controller\MountController->mount("/XXXX", null, null, null)
  3. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133 OC\AppFramework\Http\Dispatcher->executeController(OCA\FilesArchive ... {}, "mount")
  4. /usr/local/www/nextcloud/lib/private/AppFramework/App.php line 172 OC\AppFramework\Http\Dispatcher->dispatch(OCA\FilesArchive ... {}, "mount")
  5. /usr/local/www/nextcloud/lib/private/Route/Router.php line 298 OC\AppFramework\App::main("OCA\FilesArchi ... r", "mount", OC\AppFramework\ ... {}, [null,"%2FXXXX ... "])
  6. /usr/local/www/nextcloud/lib/base.php line 1030 OC\Route\Router->match("/apps/files_arc ... r")
  7. /usr/local/www/nextcloud/index.php line 36 OC::handleRequest()

POST /apps/files_archive/archive/mount /URL ENCODED PATH NAME WITH SPACES AND SO ON.rar from XXXX.XXXX.XXXX.XXXX by XXXX at 2022-11-10

— Reply to this email directly, view it on GitHub https://github.com/rotdrop/nextcloud-app-files-archive/issues/5#issuecomment-1310662466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALM54LVWIQTQZ4HY453DKLWHUYETANCNFSM6AAAAAAR4T4PYI. You are receiving this because you modified the open/close state.Message ID: @.***>

-- Claus-Justus Heine @.*** http://www.claus-justus-heine.de/

Schatzmeister der Camerata Academica Freiburg e.V. --- www.cafev.de

rotdrop commented 1 year ago

I have copied some test-files from here

https://github.com/ssokolow/rar-test-files

and also renamed one of them s.t. I got a name witch fancy multiple spaces and dots. Do you experience the problems with all .rar files? Could you try to use one from the test-files project above are provide me with a .rar files which does not work for you such that we have some common test data? Thanks.

rotdrop commented 1 year ago

I think that there are bugs in the Nextcloud software concerning adding of mime-types. I did the following:

  1. upload some .tar.xz file
  2. ok, mime-type not recognized
  3. add the mimetype to config/mimetypemapping.json: "tar.xz": ["application/x-gtar"]
  4. run ./occ maintenance:mimetype:update-db
    • this updates the oc_mimetypes table (verified, it does)
    • it updates also the oc_filecache table and sets the correct mimetypes (it does)
  5. afterwards a reload in the files-view correctly recognizes the file as archive type application/x-gtar

Then I delete the file, and do a new upload. Unfortunately the new mime-type in the newly uploaded file is again set to "I DO NOT KNOW", i.e. application/octett-stream.

So it seems the new mime-types are ignore for new files. Even worse, if one runs occ again then it does not rescan the filecache table as it thinks it has nothing to do.

I need to cross-check with a vanilla install and with NC v24/v25 if this is indeed the case. If so, I'll file an upstream bug.

rotdrop commented 1 year ago

I need to cross-check with a vanilla install and with NC v24/v25 if this is indeed the case. If so, I'll file an upstream bug.

There really seems to be an issue.

rotdrop commented 1 year ago

I need to cross-check with a vanilla install and with NC v24/v25 if this is indeed the case. If so, I'll file an upstream bug.

There really seems to be an issue.

I think the issue is the "double extension" in the mime-type. This seems not to be supported well, although this is also used in the standard resources bundle for tar.gz etc.

rotdrop commented 1 year ago

I think it is also possible to register new mime-types programmatically at run-time. This would makes things much more handy. I have to investigate further. This, however, does not resolve the issues with the double extensions like tar.gz which is an upstream issue in the Nextcloud core.

https://github.com/nextcloud/server/blob/cc8322214cc6382edfdbe92e0af120299cc3909c/lib/private/Files/Type/Detection.php#L98-L103

rotdrop commented 1 year ago

I think it is also possible to register new mime-types programmatically at run-time. This would makes things much more handy. I have to investigate further. This, however, does not resolve the issues with the double extensions like tar.gz which is an upstream issue in the Nextcloud core.

https://github.com/nextcloud/server/blob/cc8322214cc6382edfdbe92e0af120299cc3909c/lib/private/Files/Type/Detection.php#L98-L103

... well, this is an internal API, but using it would make things much easier.

rotdrop commented 1 year ago

This has been implemented in the current version. The MIME-type aliases (these control only the icons), however, need to be adjusted by an administrator. There are example config files and a little documentation in the config folder.

rotdrop commented 1 year ago

Closing as resolved by 72e241746a069672014a9454b3803f4bac22a221.