From 6f89adfa8a50111b35408678d00c8715a9ebe3b9 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont <nicolas@dandrimont.eu> Date: Fri, 7 Apr 2017 12:02:30 +0200 Subject: [PATCH] git: make GitPerm an IntEnum rather than bytes Fix T685 out of spite. While we wait for a cleaner refactoring of this code, this fixes the immediate clogging of the database with bogus data issue. --- swh/model/git.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/swh/model/git.py b/swh/model/git.py index 1f95b7b6..ad5962f5 100644 --- a/swh/model/git.py +++ b/swh/model/git.py @@ -7,7 +7,7 @@ import os import stat -from enum import Enum +from enum import Enum, IntEnum from swh.model import hashutil, identifiers @@ -25,11 +25,11 @@ class GitType(Enum): REFS = b'ref' -class GitPerm(Enum): - BLOB = b'100644' - TREE = b'40000' - EXEC = b'100755' - LINK = b'120000' +class GitPerm(IntEnum): + BLOB = 0o100644 + TREE = 0o040000 + EXEC = 0o100755 + LINK = 0o120000 def _compute_directory_git_sha1(hashes): @@ -53,7 +53,7 @@ def _compute_directory_git_sha1(hashes): [ { 'name': entry['name'], - 'perms': int(entry['perms'].value, 8), + 'perms': entry['perms'], 'target': entry['sha1_git'], 'type': 'dir' if entry['perms'] == GitPerm.TREE else 'file', } -- GitLab