Page MenuHomeSoftware Heritage

D436.diff
No OneTemporary

D436.diff

diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@
python3-sqlalchemy,
python3-swh.core,
python3-swh.loader.core (>= 0.0.32),
- python3-swh.model (>= 0.0.18),
+ python3-swh.model (>= 0.0.27),
python3-swh.scheduler (>= 0.0.14),
python3-swh.storage (>= 0.0.31),
python3-swh.storage.schemata,
@@ -24,7 +24,7 @@
Architecture: all
Depends: dpkg-dev,
python3-swh.loader.core (>= 0.0.32),
- python3-swh.model (>= 0.0.18),
+ python3-swh.model (>= 0.0.27),
python3-swh.scheduler (>= 0.0.14),
python3-swh.storage (>= 0.0.31),
python3-swh.storage.schemata,
diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,5 +1,5 @@
swh.core
swh.loader.core >= 0.0.32
-swh.model >= 0.0.18
+swh.model >= 0.0.27
swh.scheduler >= 0.0.14
swh.storage[schemata]
diff --git a/swh/loader/debian/loader.py b/swh/loader/debian/loader.py
--- a/swh/loader/debian/loader.py
+++ b/swh/loader/debian/loader.py
@@ -172,18 +172,10 @@
if isinstance(name, bytes):
name = name.decode('utf-8')
- ret = {
- 'name': name,
- }
-
- hashes = hashutil.hash_path(filepath)
- for hash in hashes:
- if hash == 'length':
- ret[hash] = hashes[hash]
- continue
- ret[hash] = hashutil.hash_to_hex(hashes[hash])
-
- return ret
+ hashes = hashutil.MultiHash.from_path(filepath).hexdigest()
+ hashes['name'] = name
+ hashes['length'] = os.path.getsize(filepath)
+ return hashes
def get_package_metadata(package, dsc_path, extracted_path):
diff --git a/swh/loader/debian/tests/__init__.py b/swh/loader/debian/tests/__init__.py
new file mode 100644
diff --git a/swh/loader/debian/tests/resources/onefile.txt b/swh/loader/debian/tests/resources/onefile.txt
new file mode 100644
--- /dev/null
+++ b/swh/loader/debian/tests/resources/onefile.txt
@@ -0,0 +1 @@
+This is a file to retrieve information from in a test context
diff --git a/swh/loader/debian/tests/test_loader.py b/swh/loader/debian/tests/test_loader.py
new file mode 100644
--- /dev/null
+++ b/swh/loader/debian/tests/test_loader.py
@@ -0,0 +1,34 @@
+# Copyright (C) 2018 The Software Heritage developers
+# See the AUTHORS file at the top-level directory of this distribution
+# License: GNU General Public License version 3, or any later version
+# See top-level LICENSE file for more information
+
+from nose.plugins.attrib import attr
+from nose.tools import istest
+from unittest import TestCase
+
+from swh.loader.debian.loader import get_file_info
+
+
+RESOURCES_PATH = './swh/loader/debian/tests/resources'
+
+
+@attr('fs')
+class TestFileInfo(TestCase):
+
+ @istest
+ def get_file_info(self):
+ path = '%s/%s' % (RESOURCES_PATH, 'onefile.txt')
+
+ actual_info = get_file_info(path)
+
+ expected_info = {
+ 'name': 'onefile.txt',
+ 'length': 62,
+ 'sha1': '135572f4ac013f49e624612301f9076af1eacef2',
+ 'sha1_git': '1d62cd247ef251d52d98bbd931d44ad1f967ea99',
+ 'sha256': '40f1a3cbe9355879319759bae1a6ba09cbf34056e79e951cd2dc0adbff169b9f', # noqa
+ 'blake2s256': '4072cf9a0017ad7705a9995bbfbbc098276e6a3afea8d84ab54bff6381c897ab', # noqa
+ }
+
+ self.assertEquals(actual_info, expected_info)

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 3:39 PM (2 w, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222423

Event Timeline