Changed: #1440 Moved more metadata utility functions

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent b1547fe1d5
commit 08acf2b63b

@ -46,16 +46,6 @@ using namespace NLMISC;
namespace PIPELINE { namespace PIPELINE {
namespace {
/// Create status file path
std::string getStatusFilePath(const std::string &path)
{
return CWorkspaceStorage::getMetaFilePath(path, PIPELINE_DATABASE_STATUS_SUFFIX);
}
} /* anonymous namespace */
CDatabaseStatus::CDatabaseStatus() CDatabaseStatus::CDatabaseStatus()
{ {
//CFile::createDirectoryTree(g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR); //CFile::createDirectoryTree(g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR);
@ -71,7 +61,7 @@ bool CDatabaseStatus::getFileStatus(CFileStatus &fileStatus, const std::string &
{ {
bool seemsValid = false; bool seemsValid = false;
std::string stdPath = unMacroPath(filePath); std::string stdPath = unMacroPath(filePath);
std::string statusPath = getStatusFilePath(filePath); std::string statusPath = CMetadataStorage::getStatusPath(filePath);
m_StatusMutex.lock_shared(); m_StatusMutex.lock_shared();
if (CMetadataStorage::readStatus(fileStatus, statusPath)) if (CMetadataStorage::readStatus(fileStatus, statusPath))
{ {
@ -222,7 +212,7 @@ public:
bool firstSeen = false; bool firstSeen = false;
uint32 time = CTime::getSecondsSince1970(); uint32 time = CTime::getSecondsSince1970();
uint32 fmdt = CFile::getFileModificationDate(FilePath); uint32 fmdt = CFile::getFileModificationDate(FilePath);
std::string statusPath = getStatusFilePath(FilePath); // g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR + dropDatabaseDirectory(FilePath) + ".status"; std::string statusPath = CMetadataStorage::getStatusPath(FilePath); // g_WorkspaceDirectory + PIPELINE_DATABASE_STATUS_SUBDIR + dropDatabaseDirectory(FilePath) + ".status";
StatusMutex->lock_shared(); StatusMutex->lock_shared();
bool statusFileExists = CMetadataStorage::readStatus(fs, statusPath); bool statusFileExists = CMetadataStorage::readStatus(fs, statusPath);
if (!statusFileExists) if (!statusFileExists)
@ -490,7 +480,7 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater,
nldebug("Created '%s'", removedTagFile.c_str()); nldebug("Created '%s'", removedTagFile.c_str());
// Delete the status. // Delete the status.
NLMISC::CFile::deleteFile(subPath); CMetadataStorage::eraseStatus(subPath);
nlinfo("Removed '%s'", subPath.c_str()); nlinfo("Removed '%s'", subPath.c_str());
} }
} }

@ -43,6 +43,10 @@ using namespace std;
namespace PIPELINE { namespace PIPELINE {
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
void CFileError::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) void CFileError::serial(NLMISC::IStream &stream) throw (NLMISC::EStream)
{ {
uint version = stream.serialVersion(1); uint version = stream.serialVersion(1);
@ -82,6 +86,15 @@ void CProjectOutput::serial(NLMISC::IStream &stream) throw (NLMISC::EStream)
stream.serialCont(FileOutputs); stream.serialCont(FileOutputs);
} }
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
std::string CMetadataStorage::getStatusPath(const std::string &file)
{
return CWorkspaceStorage::getMetaFilePath(file, PIPELINE_DATABASE_STATUS_SUFFIX);
}
bool CMetadataStorage::readStatus(CFileStatus &status, const std::string &path) bool CMetadataStorage::readStatus(CFileStatus &status, const std::string &path)
{ {
if (!NLMISC::CFile::fileExists(path)) if (!NLMISC::CFile::fileExists(path))
@ -116,6 +129,10 @@ void CMetadataStorage::eraseStatus(const std::string &path)
NLMISC::CFile::deleteFile(path); NLMISC::CFile::deleteFile(path);
} }
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
} /* namespace PIPELINE */ } /* namespace PIPELINE */
/* end of file */ /* end of file */

@ -130,10 +130,15 @@ class CMetadataStorage
public: public:
/// Note: Use the functions provided by CDatabaseStatus for manipulating status files. /// Note: Use the functions provided by CDatabaseStatus for manipulating status files.
static std::string getStatusPath(const std::string &file);
static bool readStatus(CFileStatus &status, const std::string &path); static bool readStatus(CFileStatus &status, const std::string &path);
static void writeStatus(const CFileStatus &status, const std::string &path); static void writeStatus(const CFileStatus &status, const std::string &path);
static void eraseStatus(const std::string &path); static void eraseStatus(const std::string &path);
static bool readRemove(CFileRemove &remove, const std::string & path);
static void createRemove(const CFileRemove &remove, const std::string &path); // Remove cannot be modified after creation, only erased.
static void eraseRemove(const std::string &path);
}; /* class CMetadataStorage */ }; /* class CMetadataStorage */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

Loading…
Cancel
Save