+ }
+*/
+ public static void StoreOverlayStatus(string absolutePath, FileOverlayStatus newStatus,string shortHash)
+ {
+ if (string.IsNullOrWhiteSpace(absolutePath))
+ throw new ArgumentNullException("absolutePath");
+ Contract.EndContractBlock();
+
+ ExecuteWithRetry((session, instance) =>
+ {
+ const string hqlUpdate =
+ "update FileState set OverlayStatus= :status where FilePath = :path ";
+ var updatedEntities = session.CreateQuery(hqlUpdate)
+ .SetString("path", absolutePath)
+ .SetEnum("status", newStatus)
+ .ExecuteUpdate();
+ if (updatedEntities == 0)
+ {
+ var newState = new FileState
+ {
+ FilePath = absolutePath,
+ Id = Guid.NewGuid(),
+ OverlayStatus = newStatus,
+ ShortHash = shortHash??String.Empty,
+ IsFolder=Directory.Exists(absolutePath)
+ };
+ newState.CreateAndFlush();
+ }
+ return null;
+ }, null);
+
+ }
+
+/*
+ public static void UpdateStatus(string absolutePath, FileStatus fileStatus, FileOverlayStatus overlayStatus)
+ {
+ if (string.IsNullOrWhiteSpace(absolutePath))
+ throw new ArgumentNullException("absolutePath");
+ Contract.EndContractBlock();
+
+ ExecuteWithRetry((session, instance) =>
+ {
+ const string hqlUpdate =
+ "update FileState set OverlayStatus= :overlayStatus, FileStatus= :fileStatus where FilePath = :path ";
+ var updatedEntities = session.CreateQuery(hqlUpdate)
+ .SetString("path", absolutePath)
+ .SetEnum("fileStatus", fileStatus)
+ .SetEnum("overlayStatus", overlayStatus)
+ .ExecuteUpdate();
+ return updatedEntities;
+ }, null);
+
+ }
+*/
+
+/*
+ public static void UpdateStatus(string absolutePath, FileStatus fileStatus)
+ {
+ if (string.IsNullOrWhiteSpace(absolutePath))
+ throw new ArgumentNullException("absolutePath");
+ Contract.EndContractBlock();
+
+ ExecuteWithRetry((session, instance) =>
+ {
+ const string hqlUpdate =
+ "update FileState set FileStatus= :fileStatus where FilePath = :path ";
+ var updatedEntities = session.CreateQuery(hqlUpdate)
+ .SetString("path", absolutePath)
+ .SetEnum("fileStatus", fileStatus)
+ .ExecuteUpdate();
+ return updatedEntities;
+ }, null);
+
+ }
+
+*/
+ public static void RenameState(string oldPath, string newPath)
+ {
+ if (string.IsNullOrWhiteSpace(oldPath))
+ throw new ArgumentNullException("oldPath");
+ Contract.EndContractBlock();
+
+ ExecuteWithRetry((session, instance) =>
+ {
+ const string hqlUpdate =
+ "update FileState set FilePath= :newPath where FilePath = :oldPath ";
+ var updatedEntities = session.CreateQuery(hqlUpdate)
+ .SetString("oldPath", oldPath)
+ .SetString("newPath", newPath)
+ .ExecuteUpdate();
+ return updatedEntities;
+ }, null);
+
+ }
+
+ /* public static void UpdateStatus(Guid id, FileStatus fileStatus)
+ {
+
+ ExecuteWithRetry((session, instance) =>
+ {
+ const string hqlUpdate =
+ "update FileState set FileStatus= :fileStatus where Id = :id ";
+ var updatedEntities = session.CreateQuery(hqlUpdate)
+ .SetGuid("id", id)
+ .SetEnum("fileStatus", fileStatus)
+ .ExecuteUpdate();
+ return updatedEntities;
+ }, null);
+ }*/
+
+ public static void UpdateChecksum(string absolutePath, string shortHash, string checksum)
+ {
+ if (string.IsNullOrWhiteSpace(absolutePath))
+ throw new ArgumentNullException("absolutePath");
+ Contract.EndContractBlock();