Skip to content

Commit

Permalink
[vault] fail if blob can't be hashed. Fixes MER#1306
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Sep 17, 2015
1 parent 96dc3d0 commit dbdd995
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vault.cpp
Expand Up @@ -819,10 +819,16 @@ void Unit::execScript(const QString &action)
}
}

static const int sha1HashLength = 40;

void Unit::linkBlob(const QString &file)
{
QString blobStorage = os::path::join(m_vcs->path(), ".git", "blobs");
QByteArray sha = m_vcs->hashObject(file);
if (sha.length() != sha1HashLength)
error::raise({{"msg", "Can't hash object"},
{"file", file}, {"hash", str(sha)}});

QString blobDir = os::path::join(blobStorage, sha.left(2));
QString blobFName = os::path::join(blobDir, sha.mid(2));
QString linkFName = os::path::join(m_vcs->path(), file);
Expand Down

0 comments on commit dbdd995

Please sign in to comment.