Esempio n. 1
0
        public override void UpdateItem(EntryUpdateInfo updateInfo, SyncEntryChangedFlags changeFlags)
        {
            if (updateInfo.Entry.Type == SyncEntryType.Directory)
            {
                Logger.Debug("Suppressing UpdateItem() call for Directory in BackblazeB2 adapter");
                return;
            }

            // The changeFlags parameter is passed by value, so we will modify it as we go to unset
            // the properties that we change. If we are left with a changeFlags that is non-zero,
            // then we missed a case.
            if ((changeFlags & SyncEntryChangedFlags.ModifiedTimestamp) != 0)
            {
                Pre.Assert(updateInfo.ModifiedDateTimeUtcNew != null, "updateInfo.ModifiedDateTimeUtcNew != null");

                // No action needed at the remote end. Updating the blob will update the Last-Modified
                // property. However, we do need to update the Entry.
                updateInfo.Entry.ModifiedDateTimeUtc = updateInfo.ModifiedDateTimeUtcNew.Value;

                changeFlags &= ~SyncEntryChangedFlags.ModifiedTimestamp;
            }

            if (changeFlags != SyncEntryChangedFlags.None)
            {
                throw new NotImplementedException("changeFlags = " + changeFlags);
            }
        }
Esempio n. 2
0
        public override void UpdateItem(EntryUpdateInfo updateInfo, SyncEntryChangedFlags changeFlags)
        {
            if (updateInfo.Entry.Type == SyncEntryType.Directory)
            {
                Logger.Debug("Suppressing UpdateItem() call for Directory in BackblazeB2 adapter");
                return;
            }

            throw new NotImplementedException();
        }
Esempio n. 3
0
        public EntryUpdateInfo(SyncEntry entry, AdapterBase originatingAdapter, SyncEntryChangedFlags flags, string relativePath)
        {
            Pre.ThrowIfArgumentNull(entry, "entry");
            Pre.ThrowIfArgumentNull(originatingAdapter, "originatingAdapter");

            this.Entry = entry;
            this.OriginatingAdapter = originatingAdapter;
            this.Flags        = flags;
            this.RelativePath = relativePath;

            if (flags != SyncEntryChangedFlags.None)
            {
                this.State = EntryUpdateState.NotStarted;
            }
        }
Esempio n. 4
0
        public static string GetNamesForFlags(SyncEntryChangedFlags flags)
        {
            lock (syncLock)
            {
                if (NameDictionary.TryGetValue((uint)flags, out string result))
                {
                    return(result);
                }

                result = BuildFlagString(flags);

                NameDictionary.Add((uint)flags, result);

                return(result);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string enumValue = parameter?.ToString();

            if (string.IsNullOrWhiteSpace(enumValue))
            {
                return(DependencyProperty.UnsetValue);
            }

            SyncEntryChangedFlags desiredFlag;

            if (!Enum.TryParse(enumValue, out desiredFlag))
            {
                return(DependencyProperty.UnsetValue);
            }

            if (value == null)
            {
                return(Brushes.Black);
            }

            SyncEntryChangedFlags flag = (SyncEntryChangedFlags)value;

            switch (this.Mode)
            {
            case FlagToVisibilityConverterMode.FlagIsSet:
                if ((flag & desiredFlag) != 0)
                {
                    return(Brushes.Blue);
                }
                break;

            case FlagToVisibilityConverterMode.ExactMatch:
                if (flag == desiredFlag)
                {
                    return(Brushes.Blue);
                }
                break;
            }

            return(Brushes.Black);
        }
 public override void UpdateItem(EntryUpdateInfo updateInfo, SyncEntryChangedFlags changeFlags)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
        private static string BuildFlagString(SyncEntryChangedFlags flags)
        {
            StringBuilder sb = new StringBuilder();

            if (flags == SyncEntryChangedFlags.None)
            {
                return("None");
            }

            if ((flags & SyncEntryChangedFlags.CreatedTimestamp) != 0)
            {
                sb.Append("CreatedTimestamp,");
            }

            if ((flags & SyncEntryChangedFlags.Md5Hash) != 0)
            {
                sb.Append("Md5Hash,");
            }

            if ((flags & SyncEntryChangedFlags.Sha1Hash) != 0)
            {
                sb.Append("Sha1Hash,");
            }

            if ((flags & SyncEntryChangedFlags.Deleted) != 0)
            {
                sb.Append("Deleted,");
            }

            if ((flags & SyncEntryChangedFlags.FileSize) != 0)
            {
                sb.Append("FileSize,");
            }

            if ((flags & SyncEntryChangedFlags.ModifiedTimestamp) != 0)
            {
                sb.Append("ModifiedTimestamp,");
            }

            if ((flags & SyncEntryChangedFlags.NewDirectory) != 0)
            {
                sb.Append("NewDirectory,");
            }

            if ((flags & SyncEntryChangedFlags.NewFile) != 0)
            {
                sb.Append("NewFile,");
            }

            if ((flags & SyncEntryChangedFlags.Renamed) != 0)
            {
                sb.Append("Renamed,");
            }

            if ((flags & SyncEntryChangedFlags.Restored) != 0)
            {
                sb.Append("Restored,");
            }

            if ((flags & SyncEntryChangedFlags.DestinationExists) != 0)
            {
                sb.Append("DestinationExists,");
            }

            if ((flags & SyncEntryChangedFlags.Moved) != 0)
            {
                sb.Append("Moved,");
            }

            if ((flags & SyncEntryChangedFlags.Exception) != 0)
            {
                sb.Append("Exception,");
            }

            return(sb.ToString(0, sb.Length - 1));
        }
Esempio n. 8
0
 internal static EntryUpdateInfo CreateForTests(SyncEntryChangedFlags flags, string relativePath)
 {
     return(new EntryUpdateInfo(flags, relativePath));
 }
Esempio n. 9
0
 private EntryUpdateInfo(SyncEntryChangedFlags flags, string relativePath)
 {
     this.Flags        = flags;
     this.RelativePath = relativePath;
 }
Esempio n. 10
0
 internal void SetFlags(SyncEntryChangedFlags newFlags)
 {
     this.Flags = newFlags;
 }
Esempio n. 11
0
 public bool HasSyncEntryFlag(SyncEntryChangedFlags flag)
 {
     return((this.Flags & flag) != 0);
 }
Esempio n. 12
0
        public override void UpdateItem(EntryUpdateInfo updateInfo, SyncEntryChangedFlags changeFlags)
        {
            string fullPath, newFullPath = null;

            using (var database = this.Relationship.GetDatabase())
            {
                fullPath = Path.Combine(this.Config.RootDirectory, updateInfo.Entry.GetRelativePath(database, this.PathSeparator));

                if (!string.IsNullOrWhiteSpace(updateInfo.PathNew))
                {
                    newFullPath = Path.Combine(this.Config.RootDirectory, updateInfo.PathNew);
                }
            }

            FileSystemInfo fileSystemInfo = GetFileSystemInfo(fullPath, updateInfo.Entry.Type);

            if ((changeFlags & SyncEntryChangedFlags.CreatedTimestamp) != 0)
            {
                Pre.Assert(updateInfo.CreationDateTimeUtcNew != null, "updateInfo.CreationDateTimeUtcNew != null");

                // Write the new created timestamp to the file/folder
                fileSystemInfo.CreationTimeUtc = updateInfo.CreationDateTimeUtcNew.Value;

                // Update the SyncEntry to record that this is now the "current" value of CreationDateTimeUtcNew
                updateInfo.Entry.CreationDateTimeUtc = updateInfo.CreationDateTimeUtcNew.Value;
            }

            if ((changeFlags & SyncEntryChangedFlags.ModifiedTimestamp) != 0)
            {
                Pre.Assert(updateInfo.ModifiedDateTimeUtcNew != null, "updateInfo.ModifiedDateTimeUtcNew != null");

                // Write the new modified timestamp to the file/folder
                fileSystemInfo.LastWriteTimeUtc = updateInfo.ModifiedDateTimeUtcNew.Value;

                // Update the SyncEntry to record that this is now the "current" value of ModifiedDateTimeUtcNew
                updateInfo.Entry.ModifiedDateTimeUtc = updateInfo.ModifiedDateTimeUtcNew.Value;
            }

            if ((changeFlags & SyncEntryChangedFlags.Renamed) != 0 ||
                (changeFlags & SyncEntryChangedFlags.Moved) != 0)
            {
                if (updateInfo.Entry.Type == SyncEntryType.File)
                {
                    Pre.Assert(!string.IsNullOrEmpty(newFullPath), "newFullPath != null");
                    File.Move(fullPath, newFullPath);
                }
                else if (updateInfo.Entry.Type == SyncEntryType.Directory)
                {
                    Pre.Assert(!string.IsNullOrEmpty(newFullPath), "newFullPath != null");
                    Directory.Move(fullPath, newFullPath);
                }
                else
                {
                    throw new NotImplementedException();
                }

                if ((changeFlags & SyncEntryChangedFlags.Renamed) != 0)
                {
                    updateInfo.Entry.Name = PathUtility.GetSegment(updateInfo.PathNew, -1);
                }

                if ((changeFlags & SyncEntryChangedFlags.Moved) != 0)
                {
                    updateInfo.Entry.ParentId = updateInfo.ParentIdNew;
                }
            }
        }