示例#1
0
        internal FileCompareProvider(long task, BackupRootDrive rd)
        {
            this.rootDrive = rd;
            this.taskId    = task;
            prov           = ItemProvider.GetProvider();
            //Logger.Append(Severity.INFO, "Gathering changed items since "+refBackupStart.ToString());
            //depth = 0;

            /*Index refIndex = new Index();
             * refIndex.Open(refTaskId);
             * refMaxId = refIndex.GetMaxId(rd.systemDrive.MountPoint);
             * refTaskEnumerator = refIndex.GetItemsEnumerator(rd.systemDrive.MountPoint).GetEnumerator();*/
        }
示例#2
0
        internal FileCompareProvider_old(long task, BackupRootDrive rd)
        {
            this.rootDrive = rd;
            this.taskId    = task;
            prov           = ItemProvider.GetProvider();
            //Logger.Append(Severity.INFO, "Gathering changed items since "+refBackupStart.ToString());
            //itemsToCompare = new List<IFile>();
            depth = 0;
            // get the full/synth index of reference backup, to check for renames/deletions/creations



            /*Index refIndex = new Index();
             * refIndex.Open(refTaskId);
             * refMaxId = refIndex.GetMaxId(rd.systemDrive.MountPoint);
             * refTaskEnumerator = refIndex.GetItemsEnumerator(rd.systemDrive.MountPoint).GetEnumerator();*/
        }
示例#3
0
        public IEnumerable <IFSEntry> GetNextEntry(BasePath path, string snapshottedPath)
        {
            IFileProvider itemProv = ItemProvider.GetProvider();

            try{
                if (entries == null)
                {
                    entries = GetUsnRecordsDictionary();
                }

                Logger.Append(Severity.TRIVIA, "Got " + entries.Count + " (total for whole drive)  changed entries since reference backup");
            }
            catch (Exception e) {
                Logger.Append(Severity.ERROR, "Cannot query drive USN journal : " + e.Message);
                throw(e);
            }
            // now that we got a list with only the last usn cumulated change, analyze it
            foreach (KeyValuePair <int, Win32Api.UsnEntry> entry in entries)
            {
                string ePath = "";
                Console.WriteLine(" USN entry: " + entry.ToString());
                usnJ.GetPathFromFileReference(entry.Value.FileReferenceNumber /*(ulong)entry.Key*/, out ePath);
                ePath = brd.Snapshot.MountPoint /*Path*/.TrimEnd('\\') + ePath;
                //if(ePath.ToLower().Contains("copy") ||ePath.ToLower().Contains("docs") )
                Console.WriteLine("   ///// fullpath=" + ePath);


                IFSEntry changedItem;

                /*if(((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag(NtfsUsnJournal.UsnReasonCode.USN_REASON_FILE_CREATE))
                 *      Console.WriteLine ("***  item "+ePath+" CREATED");
                 * else */
                if ((((Win32Api.UsnReasonCode)entry.Value.Reason).HasFlag(Win32Api.UsnReasonCode.USN_REASON_FILE_DELETE)))
                {
                    /*if( (((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag ( NtfsUsnJournal.UsnReasonCode.USN_REASON_FILE_CREATE )) ){
                     *      Console.WriteLine ("***  item "+entry.Value.Name+" CREATED+DELETED");
                     *      // TODO : handle deleted + created items (ID reused), if NTFS does so
                     *      continue;
                     * }*/
                    Console.WriteLine("***DELETEF###  item " + entry.Value.Name + " DELETED");
                    changedItem    = new NTBackupFile();
                    changedItem.ID = entry.Key;

                    changedItem.Name = entry.Value.Name;
                    //changedItem.BlockMetadata.BlockMetadata.Add(new DeletedItem());
                    changedItem.ChangeStatus = DataLayoutInfos.Deleted;


                    yield return(changedItem);

                    continue;
                }
                // item not corresponding to current wanted path.
                if (ePath.IndexOf(snapshottedPath) != 0)
                {
                    continue;
                }
                try{
                    changedItem          = itemProv.GetItemByPath(ePath);
                    changedItem.ParentID = (int)entry.Value.ParentFileReferenceNumber;


                    /*else/* if( (((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag ( NtfsUsnJournal.UsnReasonCode.USN_REASON_DATA_EXTEND ))
                    || (((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag ( NtfsUsnJournal.UsnReasonCode.USN_REASON_DATA_OVERWRITE ))
                    || (((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag ( NtfsUsnJournal.UsnReasonCode.USN_REASON_DATA_TRUNCATION ))
                    || (((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag ( NtfsUsnJournal.UsnReasonCode.USN_REASON_ENCRYPTION_CHANGE ))
                    ||      )
                    ||      {
                    ||      Console.WriteLine ("***  item "+ePath+" DATA MODIFIED");
                    ||      changedItem.BlockMetadata.BlockMetadata.Add(new Mod());
                    || }*/
                    /*else */ if ((((Win32Api.UsnReasonCode)entry.Value.Reason).HasFlag(Win32Api.UsnReasonCode.USN_REASON_RENAME_NEW_NAME) ||
                                   (((Win32Api.UsnReasonCode)entry.Value.Reason).HasFlag(Win32Api.UsnReasonCode.USN_REASON_RENAME_OLD_NAME))
                                   ))
                    {
                        Console.WriteLine("***RENAMED###  item " + ePath + " RENAMED ");
                        //RenamedOrMovedItem rmi = new RenamedOrMovedItem();
                        //rmi.OldName = entry.Value.OldName;
                        //changedItem.BlockMetadata.BlockMetadata.Add(rmi);

                        // check if there is data changes , additionally to rename:
                        Win32Api.UsnReasonCode newR = ((Win32Api.UsnReasonCode)entry.Value.Reason);
                        newR &= ~Win32Api.UsnReasonCode.USN_REASON_RENAME_NEW_NAME;
                        newR &= ~Win32Api.UsnReasonCode.USN_REASON_RENAME_OLD_NAME;
                        newR &= ~Win32Api.UsnReasonCode.USN_REASON_CLOSE;

                        if ((uint)newR == 0x00000000)
                        {
                            changedItem.ChangeStatus = DataLayoutInfos.RenameOnly;
                        }
                        //changedItem.BlockMetadata.BlockMetadata.Add(new UnchangedDataItem());
                    }

                    /*else if( (((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).HasFlag ( NtfsUsnJournal.UsnReasonCode.U )) )
                     *  Console.WriteLine ("***  item "+ePath+" MOVED");*/
                }
                catch (Exception e) {              //don't add item, but report it, put backup task in Warning state
                    Logger.Append(Severity.ERROR, "Could not add item '" + ePath + "', TODO : REPORT REPORT!!. " + e.Message);
                    continue;
                }
                //Console.WriteLine ("  == usn entry path="+ePath+", reason="+((NtfsUsnJournal.UsnReasonCode)entry.Value.Reason).ToString()+" ("+entry.Value.Reason+"), ID="+ (int)(entry.Value.FileReferenceNumber)+", pid="+(int)entry.Value.ParentFileReferenceNumber);
                yield return(changedItem);
            }

            //}
        }
示例#4
0
 internal FileComparer(long task, BackupRootDrive rd)
 {
     this.rootDrive = rd;
     this.taskId    = task;
     prov           = ItemProvider.GetProvider();
 }