From f529d0cafd3179418e9c944dc0ee056af76b8f00 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Tue, 2 May 2023 20:36:31 -0700 Subject: [PATCH] add support for zip archives... This imports magic.py from file-magic and merges magic_wrap.py into it... This also updates detect_from_filename to try w/ _COMPRESS, and if it returns an error, normal mode. This is necessary as [some?] zip files can be decompressed by gzip, but throws an error... --- ui/fixtures/cmd.container.zip.json | 32 ++++++ ui/fixtures/testfile.zip | Bin 0 -> 390 bytes ui/medashare/cli.py | 6 +- ui/medashare/magic.py | 111 +++++++++++++++------ ui/medashare/magic_wrap.py | 155 ----------------------------- ui/medashare/tests.py | 2 +- ui/setup.py | 1 - 7 files changed, 120 insertions(+), 187 deletions(-) create mode 100644 ui/fixtures/cmd.container.zip.json create mode 100644 ui/fixtures/testfile.zip delete mode 100644 ui/medashare/magic_wrap.py diff --git a/ui/fixtures/cmd.container.zip.json b/ui/fixtures/cmd.container.zip.json new file mode 100644 index 0000000..be14732 --- /dev/null +++ b/ui/fixtures/cmd.container.zip.json @@ -0,0 +1,32 @@ +[ +{ + "title": "gen ident", + "cmd": [ "genident", "name=A Test User" ], + "exit": 0 +}, +{ + "special": "setup file", + "file": "testfile.zip" +}, +{ + "title": "import zip container", + "cmd": [ "container", "testfile.zip" ] +}, +{ + "special": "verify store object cnt", + "comment": "should have one container and one file", + "count": 2 +}, +{ + "title": "verify correct files imported", + "cmd": [ "dump" ], + "stdout_check": [ + { "type": "identity" }, + { "files": [ "testfiles/newfile.txt", "testfiles/test.txt" ], + "hashes": [ "sha512:90f8342520f0ac57fb5a779f5d331c2fa87aa40f8799940257f9ba619940951e67143a8d746535ed0284924b2b7bc1478f095198800ba96d01847d7b56ca465c", "sha512:7d5768d47b6bc27dc4fa7e9732cfa2de506ca262a2749cb108923e5dddffde842bbfee6cb8d692fb43aca0f12946c521cce2633887914ca1f96898478d10ad3f" ], + "type": "container", + "uri": "hash://sha512/ee141c9288d3c0d240addd9d688970481ff5107bf4b437782f79afcecbc6de207d6e0900d341125a6961918608b7e9f2c53f194600d3a8326e81b182eabb9e51" }, + { "type": "file", "hashes": [ "sha512:ee141c9288d3c0d240addd9d688970481ff5107bf4b437782f79afcecbc6de207d6e0900d341125a6961918608b7e9f2c53f194600d3a8326e81b182eabb9e51" ] } + ] +} +] diff --git a/ui/fixtures/testfile.zip b/ui/fixtures/testfile.zip new file mode 100644 index 0000000000000000000000000000000000000000..64251eeff71aa4b812bd204a9bfe8126764c8ce9 GIT binary patch literal 390 zcmWIWW@h1H00D_Lze7YSJN^p;*&r;+Aj43ST3nKrnUh+qpO;z=V(67rl!S(GGB6hi zK1vFYnUq{w!Og(P@|BT+fkgzUsU#z_SOJI<6@VHPKsvYr;5K|J-Qp)C%v!_`R0zUC zC^mrXf*W6<@Hhsq@gUVeqZygxm~lB@0%!#T1JGp*OBz8e9G+o?cm~ZQ$VOwj8`