summaryrefslogtreecommitdiff
path: root/lib/backupstore/BackupStoreAccounts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backupstore/BackupStoreAccounts.cpp')
-rw-r--r--lib/backupstore/BackupStoreAccounts.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/backupstore/BackupStoreAccounts.cpp b/lib/backupstore/BackupStoreAccounts.cpp
index 5c7e4d38..8cb23a6a 100644
--- a/lib/backupstore/BackupStoreAccounts.cpp
+++ b/lib/backupstore/BackupStoreAccounts.cpp
@@ -11,6 +11,7 @@
#include <stdio.h>
+<<<<<<< HEAD
#include "BoxPortsAndFiles.h"
#include "BackupStoreAccounts.h"
#include "BackupStoreAccountDatabase.h"
@@ -19,6 +20,18 @@
#include "BackupStoreInfo.h"
#include "BackupStoreDirectory.h"
#include "BackupStoreConstants.h"
+=======
+#include "BackupStoreAccounts.h"
+#include "BackupStoreAccountDatabase.h"
+#include "BackupStoreConstants.h"
+#include "BackupStoreDirectory.h"
+#include "BackupStoreException.h"
+#include "BackupStoreInfo.h"
+#include "BackupStoreRefCountDatabase.h"
+#include "BoxPortsAndFiles.h"
+#include "RaidFileWrite.h"
+#include "StoreStructure.h"
+>>>>>>> 0.12
#include "UnixUser.h"
#include "MemLeakFindOn.h"
@@ -55,8 +68,13 @@ BackupStoreAccounts::~BackupStoreAccounts()
// Function
// Name: BackupStoreAccounts::Create(int32_t, int, int64_t, int64_t, const std::string &)
// Purpose: Create a new account on the specified disc set.
+<<<<<<< HEAD
// If rAsUsername is not empty, then the account information will be written under the
// username specified.
+=======
+// If rAsUsername is not empty, then the account information will be written under the
+// username specified.
+>>>>>>> 0.12
// Created: 2003/08/21
//
// --------------------------------------------------------------------------
@@ -102,6 +120,10 @@ void BackupStoreAccounts::Create(int32_t ID, int DiscSet, int64_t SizeSoftLimit,
std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(ID, dirName, DiscSet, false /* ReadWrite */));
info->ChangeBlocksUsed(rootDirSize);
info->ChangeBlocksInDirectories(rootDirSize);
+<<<<<<< HEAD
+=======
+ info->AdjustNumDirectories(1);
+>>>>>>> 0.12
// Save it back
info->Save();
@@ -167,4 +189,38 @@ bool BackupStoreAccounts::AccountExists(int32_t ID)
return mrDatabase.EntryExists(ID);
}
+<<<<<<< HEAD
+
+=======
+void BackupStoreAccounts::LockAccount(int32_t ID, NamedLock& rNamedLock)
+{
+ const BackupStoreAccountDatabase::Entry &en(mrDatabase.GetEntry(ID));
+ std::string rootDir = MakeAccountRootDir(ID, en.GetDiscSet());
+ int discSet = en.GetDiscSet();
+ std::string writeLockFilename;
+ StoreStructure::MakeWriteLockFilename(rootDir, discSet, writeLockFilename);
+
+ bool gotLock = false;
+ int triesLeft = 8;
+ do
+ {
+ gotLock = rNamedLock.TryAndGetLock(writeLockFilename,
+ 0600 /* restrictive file permissions */);
+
+ if(!gotLock)
+ {
+ --triesLeft;
+ ::sleep(1);
+ }
+ }
+ while (!gotLock && triesLeft > 0);
+
+ if (!gotLock)
+ {
+ THROW_EXCEPTION_MESSAGE(BackupStoreException,
+ CouldNotLockStoreAccount, "Failed to get exclusive "
+ "lock on account " << ID);
+ }
+}
+>>>>>>> 0.12