summaryrefslogtreecommitdiffstats
path: root/filedistribution
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-08-18 13:13:14 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-08-18 13:13:14 +0000
commiteac105c4f879ba2176ed08eb439681069f63f4c5 (patch)
treeebfec3f7e490a9e19f994a1ec61a09b96ae07c97 /filedistribution
parent5f829e7c6a200d94e904446c5d0f6a7308e223f1 (diff)
Signal that you need the guard while doing your stuff.
Diffstat (limited to 'filedistribution')
-rw-r--r--filedistribution/src/vespa/filedistribution/manager/filedb.cpp3
-rw-r--r--filedistribution/src/vespa/filedistribution/manager/filedb.h3
-rw-r--r--filedistribution/src/vespa/filedistribution/manager/filedistributionmanager.cpp2
3 files changed, 5 insertions, 3 deletions
diff --git a/filedistribution/src/vespa/filedistribution/manager/filedb.cpp b/filedistribution/src/vespa/filedistribution/manager/filedb.cpp
index 88621242bf6..a5c440b93a0 100644
--- a/filedistribution/src/vespa/filedistribution/manager/filedb.cpp
+++ b/filedistribution/src/vespa/filedistribution/manager/filedb.cpp
@@ -33,7 +33,8 @@ FileDB::FileDB(fs::path dbPath)
bool
-FileDB::add(fs::path original, const std::string &name) {
+FileDB::add(const DirectoryGuard & directoryGuard, fs::path original, const std::string &name) {
+ (void) directoryGuard;
fs::path finalPath = _dbPath / name;
fs::path targetPath = _dbPath / (name + ".new");
if (fs::exists(finalPath) || fs::exists(targetPath)) {
diff --git a/filedistribution/src/vespa/filedistribution/manager/filedb.h b/filedistribution/src/vespa/filedistribution/manager/filedb.h
index 6a3e5cb4e91..d5031fff8f1 100644
--- a/filedistribution/src/vespa/filedistribution/manager/filedb.h
+++ b/filedistribution/src/vespa/filedistribution/manager/filedb.h
@@ -14,11 +14,12 @@ public:
DirectoryGuard::UP getGuard() { return std::make_unique<DirectoryGuard>(_dbPath); }
/**
*
+ * @param directoryGuard The guard you need to hold in order to prevent someone fidling with your directory.
* @param original The file top copy
* @param name The name the file shall have.
* @return true if it was added, false if it was already present.
*/
- bool add(boost::filesystem::path original, const std::string& name);
+ bool add(const DirectoryGuard & directoryGuard, boost::filesystem::path original, const std::string& name);
};
} //namespace filedistribution
diff --git a/filedistribution/src/vespa/filedistribution/manager/filedistributionmanager.cpp b/filedistribution/src/vespa/filedistribution/manager/filedistributionmanager.cpp
index d2fb7b2be5b..e9147e16cb2 100644
--- a/filedistribution/src/vespa/filedistribution/manager/filedistributionmanager.cpp
+++ b/filedistribution/src/vespa/filedistribution/manager/filedistributionmanager.cpp
@@ -131,7 +131,7 @@ Java_com_yahoo_vespa_filedistribution_FileDistributionManager_addFileImpl(
NativeFileDistributionManager& manager = *nativeFileDistributionManagerField.get(self, env);
DirectoryGuard::UP guard = manager._fileDB->getGuard();// This prevents the filedistributor from working in an inconsistent state.
- bool freshlyAdded = manager._fileDB->add(completePath._value, fileReference);
+ bool freshlyAdded = manager._fileDB->add(*guard, completePath._value, fileReference);
FileDBModel& model = *manager._fileDBModel;
bool hasRegisteredFile = model.hasFile(fileReference);