public IFileSystemStructureLinkInfo MoveDirectory(DirectoryLink source, DirectoryLink destination)
        {
            lock (Client)
                Client.MoveDirectory(source.FullName, destination.FullName);

            return(GetDirectoryInfo(destination.FullName));
        }
        private static LogRowFormatter CreateLogRowForSyncObject(string responseIdentity, object syncObject, string objectInXml)
        {
            string objectId = null;
            string sourceId = null;
            string targetId = null;
            string contextId;

            if (syncObject is DirectoryObject)
            {
                DirectoryObject directoryObject = (DirectoryObject)syncObject;
                objectId  = directoryObject.ObjectId;
                contextId = directoryObject.ContextId;
            }
            else if (syncObject is DirectoryObjectError)
            {
                DirectoryObjectError directoryObjectError = (DirectoryObjectError)syncObject;
                objectId  = directoryObjectError.ObjectId;
                contextId = directoryObjectError.ContextId;
            }
            else
            {
                if (!(syncObject is DirectoryLink))
                {
                    throw new NotSupportedException("Don't know how to extract IDs for new type: " + syncObject.GetType().Name);
                }
                DirectoryLink directoryLink = (DirectoryLink)syncObject;
                contextId = directoryLink.ContextId;
                sourceId  = directoryLink.SourceId;
                targetId  = directoryLink.TargetId;
            }
            return(BackSyncAuditLog.CreateLogRow(null, null, null, responseIdentity, objectId, contextId, sourceId, targetId, objectInXml, null));
        }
        public IFileSystemStructureLinkInfo CreateDirectory(DirectoryLink directory)
        {
            lock (Client)
                Client.CreateDirectory(directory.FullName);

            return(GetDirectoryInfo(directory.FullName));
        }
        public IFileSystemStructureLinkInfo MoveDirectory(DirectoryLink source, DirectoryLink destination)
        {
            lock (File)
            {
            }

            return(GetFileInfo(destination.FullName));
        }
 public void DeleteDirectory(DirectoryLink directory, bool recursive)
 {
     lock (File)
     {
         File.BeginUpdate();
         var entry = File.GetEntry(GetDirectoryCorrectName(directory.FullName));
         File.Delete(entry);
         File.CommitUpdate();
     }
 }
        public IList <IFileSystemStructureLinkInfo> GetLinks(DirectoryLink directory, FileSystem.ListingOptions options)
        {
            var directoryName = GetDirectoryCorrectName(directory.FullName);

            lock (File)
            {
                return(File.Cast <ZipEntry>()
                       .Where(x => x.Name != directoryName && x.Name.StartsWith(directoryName))
                       .Select(x => GetInfo(x.Name, x))
                       .Cast <IFileSystemStructureLinkInfo>()
                       .ToList());
            }
        }
        public IFileSystemStructureLinkInfo CreateDirectory(DirectoryLink directory)
        {
            lock (File)
            {
                if (File.GetEntry(GetDirectoryCorrectName(directory.FullName)) == null)
                {
                    File.BeginUpdate();
                    File.AddDirectory(directory.FullName);
                    File.CommitUpdate();
                }
            }

            return(GetDirectoryInfo(directory.FullName));
        }
Beispiel #8
0
        /// <summary>
        /// Creates a file with information about files in directory.
        /// File line format: D/F   Length   Created    Modified    Hash Algorithm    Hash    Name
        /// </summary>
        /// <param name="directory">The link to the directory.</param>
        /// <param name="directoryInfoFileName">The name of file with directory information.</param>
        public static void CreateDirectoryInfo(DirectoryLink directory, string directoryInfoFileName = null)
        {
            const string empty = "-";

            directoryInfoFileName ??= HttpFileSystemOperations.DefaultDirectoryInfoFileName;

            var stack = new Stack <DirectoryLink>();

            stack.Push(directory);

            while (stack.Count > 0)
            {
                directory = stack.Pop();

                var sb = new StringBuilder();

                foreach (var link in directory.GetLinks())
                {
                    if (link.Name == directoryInfoFileName)
                    {
                        continue;
                    }
                    if (link.Type == FileSystemLinkType.Directory)
                    {
                        stack.Push((DirectoryLink)link);
                    }

                    var file = link as IFileResourceLink;
                    var hash = file?.Hash ?? FileHash.Empty;

                    sb.AppendFormat("{0}\t{1:u}\t{2:u}\t{3}\t{4}\t{5}\t{6}\n",
                                    link.Type == FileSystemLinkType.Directory ? 'D' : 'F',
                                    link.CreationTime ?? DateTime.MinValue,
                                    link.ModifyTime ?? DateTime.MinValue,
                                    file?.Length.ToString() ?? empty,
                                    hash.IsEmpty ? "-" : hash.Algorithm.ToString(),
                                    hash.IsEmpty ? "-" : hash.Value,
                                    link.Name);
                }

                directory.GetFile(directoryInfoFileName).WriteAllText(sb.ToString());
            }
        }
        public IList <IFileSystemStructureLinkInfo> GetLinks(DirectoryLink directory, FileSystem.ListingOptions options)
        {
            var items = new List <IFileSystemStructureLinkInfo>();

            lock (Client)
            {
                foreach (var line in Client.GetListing(directory.FullName, FtpListOption.SizeModify))
                {
                    if (line.Type == FtpFileSystemObjectType.Link)// || IgnoredFiles.Contains(line.Name))
                    {
                        continue;
                    }

                    var item = GetInfo(PathHelper.Combine(directory.FullName, line.Name), line);
                    items.Add(item);
                }
            }

            return(items);
        }
Beispiel #10
0
        public IList <IFileSystemStructureLinkInfo> GetLinks(DirectoryLink directory, FileSystem.ListingOptions options)
        {
            lock (Client)
            {
                string text;
                try
                {
                    text = Client.DownloadString(PathHelper.Combine(_address, directory.FullName, _directoryInfoFileName));
                }
                catch (System.Net.WebException e) when((e.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound)
                {
                    return(null);
                }

                if (!string.IsNullOrEmpty(text))
                {
                    return(ParseDirectoryInfo(directory.FullName, text).ToList());
                }
            }

            return(null);
        }
 public void DeleteDirectory(DirectoryLink directory, bool recursive)
 {
     lock (Client)
         Client.DeleteDirectory(directory.FullName);
 }
        private void SaveDirectoryLink()
        {
            if (!CanSaveDirectoryLink())
                return;

            if (m_directoryLinkInEditMode.OriginalDirectoryLink != null)
            {
                m_directoryLinkInEditMode.OriginalDirectoryLink.Copy(m_directoryLinkInEditMode);
                SelectedDirectoryLink = m_directoryLinkInEditMode.OriginalDirectoryLink;
            }
            else
            {
                DirectoryLink newLink = new DirectoryLink();
                newLink.Copy(m_directoryLinkInEditMode);
                AddStoredDirectoryLink(newLink);
                SelectedDirectoryLink = newLink;
            }

            UpdateDirectoryLinkEditButtons();

            SavePreferences();
        }
 public void AddStoredDirectoryLink(DirectoryLink link)
 {
     StoredDirectoryLinks.Add(link);
 }
Beispiel #14
0
        public DirectoryObjectsAndLinks GetMsoRawObject(SyncObjectId syncObjectId, string serviceInstanceId, bool includeBackLinks, bool includeForwardLinks, int linksResultSize, out bool?allLinksCollected)
        {
            DirectoryObjectIdentity[] array = new DirectoryObjectIdentity[]
            {
                syncObjectId.ToMsoIdentity()
            };
            DirectoryObject[]        array2 = new DirectoryObject[1];
            DirectoryLink[]          array3 = new DirectoryLink[0];
            DirectoryObjectError[]   array4 = new DirectoryObjectError[0];
            DirectoryObjectsAndLinks directoryObjectsAndLinks = new DirectoryObjectsAndLinks
            {
                NextPageToken = null,
                More          = true
            };

            byte[] msoSyncCookie = this.GetMsoSyncCookie(serviceInstanceId);
            GetDirectoryObjectsOptions?getDirectoryObjectsOptions = new GetDirectoryObjectsOptions?(GetDirectoryObjectsOptions.None);

            if (includeBackLinks)
            {
                getDirectoryObjectsOptions |= GetDirectoryObjectsOptions.IncludeBackLinks;
            }
            if (includeForwardLinks)
            {
                getDirectoryObjectsOptions |= GetDirectoryObjectsOptions.IncludeForwardLinks;
            }
            if (includeForwardLinks || includeBackLinks)
            {
                allLinksCollected = new bool?(true);
            }
            else
            {
                allLinksCollected = null;
            }
            while (directoryObjectsAndLinks.More)
            {
                GetDirectoryObjectsRequest  request          = new GetDirectoryObjectsRequest((directoryObjectsAndLinks.NextPageToken == null) ? msoSyncCookie : null, (directoryObjectsAndLinks.NextPageToken == null) ? array : null, (directoryObjectsAndLinks.NextPageToken == null) ? getDirectoryObjectsOptions : null, directoryObjectsAndLinks.NextPageToken);
                GetDirectoryObjectsResponse directoryObjects = this.SyncProxy.GetDirectoryObjects(request);
                if (directoryObjects.GetDirectoryObjectsResult.Objects != null && directoryObjects.GetDirectoryObjectsResult.Objects.Length != 0 && array2[0] == null)
                {
                    directoryObjects.GetDirectoryObjectsResult.Objects.CopyTo(array2, 0);
                }
                if (allLinksCollected == true && directoryObjects.GetDirectoryObjectsResult.Links != null && directoryObjects.GetDirectoryObjectsResult.Links.Length != 0 && array3.Length <= linksResultSize)
                {
                    if (array3.Length == linksResultSize)
                    {
                        allLinksCollected = new bool?(false);
                    }
                    else
                    {
                        int num  = array3.Length;
                        int num2 = array3.Length + directoryObjects.GetDirectoryObjectsResult.Links.Length;
                        int num3 = Math.Min(linksResultSize, num2);
                        if (num2 > linksResultSize)
                        {
                            allLinksCollected = new bool?(false);
                        }
                        Array.Resize <DirectoryLink>(ref array3, num3);
                        Array.Copy(directoryObjects.GetDirectoryObjectsResult.Links, 0, array3, num, num3 - num);
                    }
                }
                if (directoryObjects.GetDirectoryObjectsResult.Errors != null && directoryObjects.GetDirectoryObjectsResult.Errors.Length != 0)
                {
                    Array.Resize <DirectoryObjectError>(ref array4, array4.Length + directoryObjects.GetDirectoryObjectsResult.Errors.Length);
                    directoryObjects.GetDirectoryObjectsResult.Errors.CopyTo(array4, array4.Length - directoryObjects.GetDirectoryObjectsResult.Errors.Length);
                }
                directoryObjectsAndLinks.NextPageToken = directoryObjects.GetDirectoryObjectsResult.NextPageToken;
                directoryObjectsAndLinks.More          = directoryObjects.GetDirectoryObjectsResult.More;
            }
            directoryObjectsAndLinks.Objects = ((array2 != null && array2[0] != null) ? array2 : new DirectoryObject[0]);
            directoryObjectsAndLinks.Links   = array3;
            directoryObjectsAndLinks.Errors  = array4;
            return(directoryObjectsAndLinks);
        }