Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[vault] fail if blob can't be hashed. Fixes MER#1306
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Sep 29, 2015
1 parent 194e92a commit ac6aa93
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vault.cpp
Expand Up @@ -32,6 +32,8 @@ namespace debug = qtaround::debug;

namespace vault {

static const int sha1HashLength = 40;

static const QMap<File, QString> fileNames = {
{File::Message, ".message"}
, {File::VersionTree, ".vault"}
Expand Down Expand Up @@ -661,6 +663,10 @@ struct Unit
{
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 ac6aa93

Please sign in to comment.