Commit b67747fd authored by Antoine Millet's avatar Antoine Millet
Browse files

Added option to repository to return an empty file when the file is missing

parent 908742d2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ class Repository(object):
                self._objects[name] = tql_object
            return obj_id

    def load(self, name):
    def load(self, name, empty_if_missing=False):
        """ Load a file from the repository and compute its sha1sum.

        :return: a tuple (sha1_hash, content)
@@ -88,6 +88,8 @@ class Repository(object):
            with open(fullname, 'r') as ffile:
                content = ffile.read()
        except IOError as err:
            if empty_if_missing and err.errno == 2:
                return sha1('').hexdigest(), ''
            msg = 'Error while saving: %s' % err
            raise RepositoryOperationError(msg)
        else: