Esempio n. 1
0
 private static void Compare(SyncFileData syncFileData, SyncDirectory syncDirA, SyncDirectory syncDirB)
 {
     var fileInfoHelper = new FileInfoHelper();
     var syncFile = syncDirB.SyncFileData.SingleOrDefault(f => f.Name == syncFileData.Name);
     if (syncFile == null)
     {
         fileInfoHelper.Copy(syncFileData, syncDirA, syncDirB);
     }
     else
     {
         if (syncFileData.Logs.Last().Hash != syncFile.Logs.Last().Hash)
         {
             if (syncFileData.Logs.Last().Date > syncFile.Logs.Last().Date)
             {
                 //fm.Copy(syncDirA, syncDirB, syncFileData);
             }
         }
         else
         {
             if (syncFileData.Logs.Last().Date > syncFile.Logs.Last().Date)
             {
                 // fm.Copy(syncDirB, syncDirA, syncFileData);
             }
         }
     }
 }
Esempio n. 2
0
        private static void UpdateDirectory(SyncDirectory syncDirA, SyncDirectory syncDirB)
        {
            var fm = new FileInfoHelper();
            syncDirA.SyncFileData.ToList().ForEach(syncFileData => { Compare(syncFileData, syncDirA, syncDirB); });

            fm.WriteToSyncFile(syncDirB);
        }
Esempio n. 3
0
        private static void Start(string[] args)
        {
            var fileHelper = new FileInfoHelper();

            var dirs = fileHelper.GetDirectoryInfo(args).ToList();

            var syncDirA = new SyncDirectory(dirs.ElementAt(0));
            var syncDirB = new SyncDirectory(dirs.ElementAt(1));

            var syncMan = new SyncManager();
            syncMan.Sync(syncDirA, syncDirB);
        }
 public static SyncFileData ToSyncFileData(this FileInfo fileInfo)
 {
     var fm = new FileInfoHelper();
     return new SyncFileData
     {
         Name = fileInfo.Name,
         Logs = new List<Log>
         {
             new Log
             {
                 Date = fileInfo.LastWriteTimeUtc,
                 Hash = fm.GetFileHash(fileInfo)
             }
         }
     };
 }