Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #22 from nemomobile/mer1306-fail-if-hash-object-fa…
…iled

[vault] fail if blob can't be hashed. Fixes MER#1306
  • Loading branch information
Denis Zalevskiy committed Sep 29, 2015
2 parents 194e92a + ac6aa93 commit 990caca
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 990caca

Please sign in to comment.