2 /* -----------------------------------------------------------------------
3 * <copyright file="StatusAgent.cs" company="GRNet">
5 * Copyright 2011-2012 GRNET S.A. All rights reserved.
7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following
11 * 1. Redistributions of source code must retain the above
12 * copyright notice, this list of conditions and the following
15 * 2. Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * The views and conclusions contained in the software and
35 * documentation are those of the authors and should not be
36 * interpreted as representing official policies, either expressed
37 * or implied, of GRNET S.A.
39 * -----------------------------------------------------------------------
43 using System.Collections.Generic;
44 using System.ComponentModel.Composition;
45 using System.Data.SQLite;
46 using System.Diagnostics;
47 using System.Diagnostics.Contracts;
50 using System.Reflection;
51 using System.Security.Cryptography;
53 using System.Threading;
54 using System.Threading.Tasks;
55 using Castle.ActiveRecord;
56 using Castle.ActiveRecord.Framework;
57 using Castle.ActiveRecord.Framework.Config;
58 using NHibernate.ByteCode.Castle;
60 using NHibernate.Cfg.Loquacious;
61 using NHibernate.Dialect;
62 using Pithos.Interfaces;
65 using Environment = System.Environment;
67 namespace Pithos.Core.Agents
69 [Export(typeof(IStatusChecker)),Export(typeof(IStatusKeeper))]
70 public class StatusAgent:IStatusChecker,IStatusKeeper
72 private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
74 [System.ComponentModel.Composition.Import]
75 public IPithosSettings Settings { get; set; }
77 private Agent<Action> _persistenceAgent;
83 var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
85 _pithosDataPath = Path.Combine(appDataPath , "GRNET\\PITHOS");
86 if (!Directory.Exists(_pithosDataPath))
87 Directory.CreateDirectory(_pithosDataPath);
89 var dbPath = Path.Combine(_pithosDataPath, "pithos.db");
91 MigrateOldDb(dbPath, appDataPath);
94 var source = GetConfiguration(_pithosDataPath);
95 ActiveRecordStarter.Initialize(source,typeof(FileState),typeof(FileTag));
97 ActiveRecordStarter.UpdateSchema();
100 if (!File.Exists(dbPath))
101 ActiveRecordStarter.CreateSchema();
108 private static void MigrateOldDb(string dbPath, string appDataPath)
110 Contract.Requires(!String.IsNullOrWhiteSpace(dbPath));
111 Contract.Requires(!String.IsNullOrWhiteSpace(appDataPath));
114 var oldDbPath = Path.Combine(appDataPath, "Pithos", "pithos.db");
115 var oldDbInfo = new FileInfo(oldDbPath);
116 if (oldDbInfo.Exists && !File.Exists(dbPath))
118 Log.InfoFormat("Moving database from {0} to {1}",oldDbInfo.FullName,dbPath);
119 var oldDirectory = oldDbInfo.Directory;
120 oldDbInfo.MoveTo(dbPath);
122 if (Log.IsDebugEnabled)
123 Log.DebugFormat("Deleting {0}",oldDirectory.FullName);
125 oldDirectory.Delete(true);
129 private void CreateTrigger()
131 using (var connection = GetConnection())
132 using (var triggerCommand = connection.CreateCommand())
134 var cmdText = new StringBuilder()
135 .AppendLine("CREATE TRIGGER IF NOT EXISTS update_last_modified UPDATE ON FileState FOR EACH ROW")
137 .AppendLine("UPDATE FileState SET Modified=datetime('now') WHERE Id=old.Id;")
139 .AppendLine("CREATE TRIGGER IF NOT EXISTS insert_last_modified INSERT ON FileState FOR EACH ROW")
141 .AppendLine("UPDATE FileState SET Modified=datetime('now') WHERE Id=new.Id;")
144 triggerCommand.CommandText = cmdText;
145 triggerCommand.ExecuteNonQuery();
150 private static InPlaceConfigurationSource GetConfiguration(string pithosDbPath)
152 if (String.IsNullOrWhiteSpace(pithosDbPath))
153 throw new ArgumentNullException("pithosDbPath");
154 if (!Path.IsPathRooted(pithosDbPath))
155 throw new ArgumentException("path must be a rooted path", "pithosDbPath");
156 Contract.EndContractBlock();
158 var properties = new Dictionary<string, string>
160 {"connection.driver_class", "NHibernate.Driver.SQLite20Driver"},
161 {"dialect", "NHibernate.Dialect.SQLiteDialect"},
162 {"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
164 "proxyfactory.factory_class",
165 "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"
169 var connectionString = String.Format(@"Data Source={0}\pithos.db;Version=3;Enlist=N", pithosDbPath);
170 properties.Add("connection.connection_string", connectionString);
172 var source = new InPlaceConfigurationSource();
173 source.Add(typeof (ActiveRecordBase), properties);
174 source.SetDebugFlag(false);
178 public void StartProcessing(CancellationToken token)
180 _persistenceAgent = Agent<Action>.Start(queue =>
185 var job = queue.Receive();
186 job.ContinueWith(t =>
188 var action = job.Result;
193 catch (SQLiteException ex)
195 Log.ErrorFormat("[ERROR] SQL \n{0}", ex);
199 Log.ErrorFormat("[ERROR] STATE \n{0}", ex);
201 queue.NotifyComplete(action);
202 // ReSharper disable AccessToModifiedClosure
204 // ReSharper restore AccessToModifiedClosure
216 _persistenceAgent.Stop();
220 public void ProcessExistingFiles(IEnumerable<FileInfo> existingFiles)
222 if(existingFiles ==null)
223 throw new ArgumentNullException("existingFiles");
224 Contract.EndContractBlock();
226 //Find new or matching files with a left join to the stored states
227 var fileStates = FileState.Queryable;
228 var currentFiles=from file in existingFiles
229 join state in fileStates on file.FullName.ToLower() equals state.FilePath.ToLower() into gs
230 from substate in gs.DefaultIfEmpty()
231 select new {File = file, State = substate};
233 //To get the deleted files we must get the states that have no corresponding
235 //We can't use the File.Exists method inside a query, so we get all file paths from the states
236 var statePaths = (from state in fileStates
237 select new {state.Id, state.FilePath}).ToList();
239 var missingStates= (from path in statePaths
240 where !File.Exists(path.FilePath) && !Directory.Exists(path.FilePath)
241 select path.Id).ToList();
242 //Finally, retrieve the states that correspond to the deleted files
243 var deletedFiles = from state in fileStates
244 where missingStates.Contains(state.Id)
245 select new { File = default(FileInfo), State = state };
247 var pairs = currentFiles.Union(deletedFiles).ToList();
249 using (var shortHasher = HashAlgorithm.Create("sha1"))
251 foreach (var pair in pairs)
253 var fileState = pair.State;
254 var file = pair.File;
255 if (fileState == null)
258 var createState = FileState.CreateFor(file);
259 _persistenceAgent.Post(createState.Create);
261 else if (file == null)
263 //This file was deleted while we were down. We should mark it as deleted
264 //We have to go through UpdateStatus here because the state object we are using
265 //was created by a different ORM session.
266 _persistenceAgent.Post(() => UpdateStatusDirect(fileState.Id, FileStatus.Deleted));
270 //This file has a matching state. Need to check for possible changes
271 //To check for changes, we use the cheap (in CPU terms) SHA1 algorithm
272 //on the entire file.
274 var hashString = file.ComputeShortHash(shortHasher);
275 //TODO: Need a way to attach the hashes to the filestate so we don't
276 //recalculate them each time a call to calculate has is made
277 //We can either store them to the filestate or add them to a
280 //If the hashes don't match the file was changed
281 if (fileState.ShortHash != hashString)
283 _persistenceAgent.Post(() => UpdateStatusDirect(fileState.Id, FileStatus.Modified));
294 private int UpdateStatusDirect(Guid id, FileStatus status)
296 using (log4net.ThreadContext.Stacks["StatusAgent"].Push("UpdateStatusDirect"))
302 using (var connection = GetConnection())
304 var command = new SQLiteCommand("update FileState set FileStatus= :fileStatus where Id = :id ",
307 command.Parameters.AddWithValue("fileStatus", status);
309 command.Parameters.AddWithValue("id", id);
311 var affected = command.ExecuteNonQuery();
317 catch (Exception exc)
319 Log.Error(exc.ToString());
325 private int UpdateStatusDirect(string path, FileStatus status)
327 using (log4net.ThreadContext.Stacks["StatusAgent"].Push("UpdateStatusDirect"))
334 using (var connection = GetConnection())
337 new SQLiteCommand("update FileState set FileStatus= :fileStatus where FilePath = :path COLLATE NOCASE",
342 command.Parameters.AddWithValue("fileStatus", status);
344 command.Parameters.AddWithValue("path", path);
346 var affected = command.ExecuteNonQuery();
350 catch (Exception exc)
352 Log.Error(exc.ToString());
358 private int UpdateStatusDirect(string absolutePath, FileStatus fileStatus, FileOverlayStatus overlayStatus)
360 using (log4net.ThreadContext.Stacks["StatusAgent"].Push("UpdateStatusDirect"))
367 using (var connection = GetConnection())
371 "update FileState set OverlayStatus= :overlayStatus, FileStatus= :fileStatus where FilePath = :path COLLATE NOCASE ",
375 command.Parameters.AddWithValue("path", absolutePath);
376 command.Parameters.AddWithValue("fileStatus", fileStatus);
377 command.Parameters.AddWithValue("overlayStatus", overlayStatus);
379 var affected = command.ExecuteNonQuery();
383 catch (Exception exc)
385 Log.Error(exc.ToString());
393 public string BlockHash { get; set; }
395 public int BlockSize { get; set; }
396 public void ChangeRoots(string oldPath, string newPath)
398 if (String.IsNullOrWhiteSpace(oldPath))
399 throw new ArgumentNullException("oldPath");
400 if (!Path.IsPathRooted(oldPath))
401 throw new ArgumentException("oldPath must be an absolute path", "oldPath");
402 if (string.IsNullOrWhiteSpace(newPath))
403 throw new ArgumentNullException("newPath");
404 if (!Path.IsPathRooted(newPath))
405 throw new ArgumentException("newPath must be an absolute path", "newPath");
406 Contract.EndContractBlock();
408 FileState.ChangeRootPath(oldPath,newPath);
414 private readonly string _pithosDataPath;
417 public FileState GetStateByFilePath(string path)
419 if (String.IsNullOrWhiteSpace(path))
420 throw new ArgumentNullException("path");
421 if (!Path.IsPathRooted(path))
422 throw new ArgumentException("The path must be rooted", "path");
423 Contract.EndContractBlock();
428 using (var connection = GetConnection())
429 using (var command = new SQLiteCommand("select Id, FilePath, OverlayStatus,FileStatus ,Checksum ,ShortHash,Version ,VersionTimeStamp,IsShared ,SharedBy ,ShareWrite from FileState where FilePath=:path COLLATE NOCASE", connection))
432 command.Parameters.AddWithValue("path", path);
434 using (var reader = command.ExecuteReader())
438 //var values = new object[reader.FieldCount];
439 //reader.GetValues(values);
440 var state = new FileState
442 Id = reader.GetGuid(0),
443 FilePath = reader.IsDBNull(1)?"":reader.GetString(1),
444 OverlayStatus =reader.IsDBNull(2)?FileOverlayStatus.Unversioned: (FileOverlayStatus) reader.GetInt64(2),
445 FileStatus = reader.IsDBNull(3)?FileStatus.Missing:(FileStatus) reader.GetInt64(3),
446 Checksum = reader.IsDBNull(4)?"":reader.GetString(4),
447 ShortHash= reader.IsDBNull(5)?"":reader.GetString(5),
448 Version = reader.IsDBNull(6)?default(long):reader.GetInt64(6),
449 VersionTimeStamp = reader.IsDBNull(7)?default(DateTime):reader.GetDateTime(7),
450 IsShared = !reader.IsDBNull(8) && reader.GetBoolean(8),
451 SharedBy = reader.IsDBNull(9)?"":reader.GetString(9),
452 ShareWrite = !reader.IsDBNull(10) && reader.GetBoolean(10)
455 var state = new FileState
457 Id = (Guid) values[0],
458 FilePath = (string) values[1],
459 OverlayStatus = (FileOverlayStatus) (long)values[2],
460 FileStatus = (FileStatus) (long)values[3],
461 Checksum = (string) values[4],
462 Version = (long?) values[5],
463 VersionTimeStamp = (DateTime?) values[6],
464 IsShared = (long)values[7] == 1,
465 SharedBy = (string) values[8],
466 ShareWrite = (long)values[9] == 1
479 catch (Exception exc)
481 Log.ErrorFormat(exc.ToString());
486 public FileOverlayStatus GetFileOverlayStatus(string path)
488 if (String.IsNullOrWhiteSpace(path))
489 throw new ArgumentNullException("path");
490 if (!Path.IsPathRooted(path))
491 throw new ArgumentException("The path must be rooted", "path");
492 Contract.EndContractBlock();
497 using (var connection = GetConnection())
498 using (var command = new SQLiteCommand("select OverlayStatus from FileState where FilePath=:path COLLATE NOCASE", connection))
501 command.Parameters.AddWithValue("path", path);
503 var s = command.ExecuteScalar();
504 return (FileOverlayStatus) Convert.ToInt32(s);
507 catch (Exception exc)
509 Log.ErrorFormat(exc.ToString());
510 return FileOverlayStatus.Unversioned;
514 private string GetConnectionString()
516 var connectionString = String.Format(@"Data Source={0}\pithos.db;Version=3;Enlist=N;Pooling=True", _pithosDataPath);
517 return connectionString;
520 private SQLiteConnection GetConnection()
522 var connectionString = GetConnectionString();
523 var connection = new SQLiteConnection(connectionString);
525 using(var cmd =connection.CreateCommand())
527 cmd.CommandText = "PRAGMA journal_mode=WAL";
528 cmd.ExecuteNonQuery();
533 /* public void SetFileOverlayStatus(string path, FileOverlayStatus overlayStatus)
535 if (String.IsNullOrWhiteSpace(path))
536 throw new ArgumentNullException("path");
537 if (!Path.IsPathRooted(path))
538 throw new ArgumentException("The path must be rooted","path");
539 Contract.EndContractBlock();
541 _persistenceAgent.Post(() => FileState.StoreOverlayStatus(path,overlayStatus));
544 public Task SetFileOverlayStatus(string path, FileOverlayStatus overlayStatus, string shortHash = null)
546 if (String.IsNullOrWhiteSpace(path))
547 throw new ArgumentNullException("path");
548 if (!Path.IsPathRooted(path))
549 throw new ArgumentException("The path must be rooted","path");
550 Contract.EndContractBlock();
552 return _persistenceAgent.PostAndAwait(() => FileState.StoreOverlayStatus(path,overlayStatus,shortHash));
555 /* public void RenameFileOverlayStatus(string oldPath, string newPath)
557 if (String.IsNullOrWhiteSpace(oldPath))
558 throw new ArgumentNullException("oldPath");
559 if (!Path.IsPathRooted(oldPath))
560 throw new ArgumentException("The oldPath must be rooted", "oldPath");
561 if (String.IsNullOrWhiteSpace(newPath))
562 throw new ArgumentNullException("newPath");
563 if (!Path.IsPathRooted(newPath))
564 throw new ArgumentException("The newPath must be rooted", "newPath");
565 Contract.EndContractBlock();
567 _persistenceAgent.Post(() =>FileState.RenameState(oldPath, newPath));
570 public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus)
572 if (String.IsNullOrWhiteSpace(path))
573 throw new ArgumentNullException("path");
574 if (!Path.IsPathRooted(path))
575 throw new ArgumentException("The path must be rooted", "path");
576 Contract.EndContractBlock();
578 Debug.Assert(!path.Contains(FolderConstants.CacheFolder));
579 Debug.Assert(!path.EndsWith(".ignore"));
581 _persistenceAgent.Post(() => UpdateStatusDirect(path, fileStatus, overlayStatus));
585 public void StoreInfo(string path,ObjectInfo objectInfo)
587 if (String.IsNullOrWhiteSpace(path))
588 throw new ArgumentNullException("path");
589 if (!Path.IsPathRooted(path))
590 throw new ArgumentException("The path must be rooted", "path");
591 if (objectInfo == null)
592 throw new ArgumentNullException("objectInfo", "objectInfo can't be empty");
593 Contract.EndContractBlock();
595 _persistenceAgent.Post(() =>
597 var filePath = path.ToLower();
598 //Load the existing files state and set its properties in one session
599 using (new SessionScope())
601 //Forgetting to use a sessionscope results in two sessions being created, one by
602 //FirstOrDefault and one by Save()
603 var state =FileState.FindByFilePath(filePath);
605 //Create a new empty state object if this is a new file
606 state = state ?? new FileState();
608 state.FilePath = filePath;
609 state.Checksum = objectInfo.Hash;
610 state.Version = objectInfo.Version;
611 state.VersionTimeStamp = objectInfo.VersionTimestamp;
613 state.FileStatus = FileStatus.Unchanged;
614 state.OverlayStatus = FileOverlayStatus.Normal;
625 public void StoreInfo(string path, ObjectInfo objectInfo)
627 if (String.IsNullOrWhiteSpace(path))
628 throw new ArgumentNullException("path");
629 if (!Path.IsPathRooted(path))
630 throw new ArgumentException("The path must be rooted", "path");
631 if (objectInfo == null)
632 throw new ArgumentNullException("objectInfo", "objectInfo can't be empty");
633 Contract.EndContractBlock();
635 _persistenceAgent.Post(() => StoreInfoDirect(path, objectInfo));
639 private void StoreInfoDirect(string path, ObjectInfo objectInfo)
644 using (var connection = GetConnection())
645 using (var command = new SQLiteCommand(connection))
647 if (StateExists(path, connection))
648 command.CommandText =
649 "update FileState set FileStatus= :fileStatus where FilePath = :path COLLATE NOCASE ";
652 command.CommandText =
653 "INSERT INTO FileState (Id,FilePath,Checksum,Version,VersionTimeStamp,ShortHash,FileStatus,OverlayStatus) VALUES (:id,:path,:checksum,:version,:versionTimeStamp,:shortHash,:fileStatus,:overlayStatus)";
654 command.Parameters.AddWithValue("id", Guid.NewGuid());
657 command.Parameters.AddWithValue("path", path);
658 command.Parameters.AddWithValue("checksum", objectInfo.Hash);
659 command.Parameters.AddWithValue("shortHash", "");
660 command.Parameters.AddWithValue("version", objectInfo.Version);
661 command.Parameters.AddWithValue("versionTimeStamp",
662 objectInfo.VersionTimestamp);
663 command.Parameters.AddWithValue("fileStatus", FileStatus.Unchanged);
664 command.Parameters.AddWithValue("overlayStatus",
665 FileOverlayStatus.Normal);
667 var affected = command.ExecuteNonQuery();
671 catch (Exception exc)
673 Log.Error(exc.ToString());
678 private bool StateExists(string filePath,SQLiteConnection connection)
680 using (var command = new SQLiteCommand("Select count(*) from FileState where FilePath=:path COLLATE NOCASE", connection))
682 command.Parameters.AddWithValue("path", filePath);
683 var result = command.ExecuteScalar();
684 return ((long)result >= 1);
689 public void SetFileStatus(string path, FileStatus status)
691 if (String.IsNullOrWhiteSpace(path))
692 throw new ArgumentNullException("path");
693 if (!Path.IsPathRooted(path))
694 throw new ArgumentException("The path must be rooted", "path");
695 Contract.EndContractBlock();
697 _persistenceAgent.Post(() => UpdateStatusDirect(path, status));
700 public FileStatus GetFileStatus(string path)
702 if (String.IsNullOrWhiteSpace(path))
703 throw new ArgumentNullException("path");
704 if (!Path.IsPathRooted(path))
705 throw new ArgumentException("The path must be rooted", "path");
706 Contract.EndContractBlock();
709 using (var connection = GetConnection())
711 var command = new SQLiteCommand("select FileStatus from FileState where FilePath=:path COLLATE NOCASE", connection);
712 command.Parameters.AddWithValue("path", path);
714 var statusValue = command.ExecuteScalar();
715 if (statusValue==null)
716 return FileStatus.Missing;
717 return (FileStatus)Convert.ToInt32(statusValue);
722 /// Deletes the status of the specified file
724 /// <param name="path"></param>
725 public void ClearFileStatus(string path)
727 if (String.IsNullOrWhiteSpace(path))
728 throw new ArgumentNullException("path");
729 if (!Path.IsPathRooted(path))
730 throw new ArgumentException("The path must be rooted", "path");
731 Contract.EndContractBlock();
733 _persistenceAgent.Post(() => DeleteDirect(path));
737 /// Deletes the status of the specified folder and all its contents
739 /// <param name="path"></param>
740 public void ClearFolderStatus(string path)
742 if (String.IsNullOrWhiteSpace(path))
743 throw new ArgumentNullException("path");
744 if (!Path.IsPathRooted(path))
745 throw new ArgumentException("The path must be rooted", "path");
746 Contract.EndContractBlock();
748 _persistenceAgent.Post(() => DeleteFolderDirect(path));
751 public IEnumerable<FileState> GetChildren(FileState fileState)
753 if (fileState == null)
754 throw new ArgumentNullException("fileState");
755 Contract.EndContractBlock();
757 var children = from state in FileState.Queryable
758 where state.FilePath.StartsWith(fileState.FilePath + "\\")
763 public void EnsureFileState(string path)
765 var existingState = GetStateByFilePath(path);
766 if (existingState != null)
768 var fileInfo = FileInfoExtensions.FromPath(path);
769 using (new SessionScope())
771 var newState = FileState.CreateFor(fileInfo);
772 newState.FileStatus=FileStatus.Missing;
773 _persistenceAgent.PostAndAwait(newState.CreateAndFlush).Wait();
778 private int DeleteDirect(string filePath)
780 using (log4net.ThreadContext.Stacks["StatusAgent"].Push("DeleteDirect"))
787 using (var connection = GetConnection())
789 var command = new SQLiteCommand("delete from FileState where FilePath = :path COLLATE NOCASE",
792 command.Parameters.AddWithValue("path", filePath);
794 var affected = command.ExecuteNonQuery();
798 catch (Exception exc)
800 Log.Error(exc.ToString());
806 private int DeleteFolderDirect(string filePath)
808 using (log4net.ThreadContext.Stacks["StatusAgent"].Push("DeleteDirect"))
815 using (var connection = GetConnection())
817 var command = new SQLiteCommand(@"delete from FileState where FilePath = :path or FilePath like :path || '\%' COLLATE NOCASE",
820 command.Parameters.AddWithValue("path", filePath);
822 var affected = command.ExecuteNonQuery();
826 catch (Exception exc)
828 Log.Error(exc.ToString());
834 public void UpdateFileChecksum(string path, string shortHash, string checksum)
836 if (String.IsNullOrWhiteSpace(path))
837 throw new ArgumentNullException("path");
838 if (!Path.IsPathRooted(path))
839 throw new ArgumentException("The path must be rooted", "path");
840 Contract.EndContractBlock();
842 _persistenceAgent.Post(() => FileState.UpdateChecksum(path, shortHash,checksum));