void AddSubDirectory(WorkspaceDirectoryInfo NewWorkspaceDir, StreamDirectoryInfo StreamSubDir, ThreadPoolWorkQueue Queue)
        {
            WorkspaceDirectoryInfo NewWorkspaceSubDir = new WorkspaceDirectoryInfo(NewWorkspaceDir, StreamSubDir.Name);

            NewWorkspaceDir.NameToSubDirectory.Add(StreamSubDir.Name, NewWorkspaceSubDir);
            Queue.Enqueue(() => AddDirectory(NewWorkspaceSubDir, StreamSubDir, Queue));
        }
 /// <summary>
 /// Constructor for reading a file info from disk
 /// </summary>
 /// <param name="Reader">Binary reader to read data from</param>
 /// <param name="Directory">Parent directory</param>
 public StreamFileInfo(BinaryReader Reader, StreamDirectoryInfo Directory)
 {
     this.Name                 = Reader.ReadString();
     this.Length               = Reader.ReadInt64();
     this.ContentId            = new FileContentId(Reader);
     this.Directory            = Directory;
     this.DepotFileAndRevision = Reader.ReadString();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Name">Name of this file</param>
 /// <param name="Length">Length of the file on the server</param>
 /// <param name="ContentId">Content id for this file</param>
 /// <param name="Directory">The parent directory</param>
 /// <param name="DepotFileAndRevision">The depot file and revision that need to be synced for this file</param>
 public StreamFileInfo(string Name, long Length, FileContentId ContentId, StreamDirectoryInfo Directory, string DepotFileAndRevision)
 {
     this.Name                 = Name;
     this.Length               = Length;
     this.ContentId            = ContentId;
     this.Directory            = Directory;
     this.DepotFileAndRevision = DepotFileAndRevision;
 }
Beispiel #4
0
        public WorkspaceTransactionRemove(WorkspaceDirectoryInfo WorkspaceRootDir, StreamDirectoryInfo StreamRootDir, Dictionary <FileContentId, TrackedFileInfo> ContentIdToTrackedFile)
        {
            this.NewWorkspaceRootDir    = new WorkspaceDirectoryInfo(WorkspaceRootDir.GetLocation());
            this.ContentIdToTrackedFile = ContentIdToTrackedFile;

            using (ThreadPoolWorkQueue Queue = new ThreadPoolWorkQueue())
            {
                Queue.Enqueue(() => Merge(WorkspaceRootDir, NewWorkspaceRootDir, StreamRootDir, Queue));
            }
        }
        void AddDirectory(WorkspaceDirectoryInfo NewWorkspaceDir, StreamDirectoryInfo StreamDir, ThreadPoolWorkQueue Queue)
        {
            // Make sure the directory exists
            Directory.CreateDirectory(NewWorkspaceDir.GetFullName());

            // Add all the sub directories and files
            foreach (StreamDirectoryInfo StreamSubDir in StreamDir.NameToSubDirectory.Values)
            {
                AddSubDirectory(NewWorkspaceDir, StreamSubDir, Queue);
            }
            foreach (StreamFileInfo StreamFile in StreamDir.NameToFile.Values)
            {
                AddFile(NewWorkspaceDir, StreamFile);
            }
        }
        public WorkspaceTransactionAdd(WorkspaceDirectoryInfo WorkspaceRootDir, StreamDirectoryInfo StreamRootDir, Dictionary <FileContentId, TrackedFileInfo> ContentIdToTrackedFile)
        {
            this.NewWorkspaceRootDir = new WorkspaceDirectoryInfo(WorkspaceRootDir.GetLocation());

            this.ContentIdToTrackedFile = ContentIdToTrackedFile;

            List <WorkspaceFileInfo> WorkspaceFiles = WorkspaceRootDir.GetFiles();

            foreach (WorkspaceFileInfo WorkspaceFile in WorkspaceFiles)
            {
                ContentIdToWorkspaceFile[WorkspaceFile.ContentId] = WorkspaceFile;
            }

            using (ThreadPoolWorkQueue Queue = new ThreadPoolWorkQueue())
            {
                Queue.Enqueue(() => MergeDirectory(WorkspaceRootDir, NewWorkspaceRootDir, StreamRootDir, Queue));
            }
        }
        /// <summary>
        /// Constructor for reading from disk
        /// </summary>
        /// <param name="Reader">Reader to read data from</param>
        /// <param name="ParentDirectory">The parent directory to initialize this directory with</param>
        public StreamDirectoryInfo(BinaryReader Reader, StreamDirectoryInfo ParentDirectory)
        {
            this.Name            = Reader.ReadString();
            this.ParentDirectory = ParentDirectory;

            int NumFiles = Reader.ReadInt32();

            for (int Idx = 0; Idx < NumFiles; Idx++)
            {
                StreamFileInfo File = new StreamFileInfo(Reader, this);
                NameToFile.Add(File.Name, File);
            }

            int NumDirectories = Reader.ReadInt32();

            for (int Idx = 0; Idx < NumDirectories; Idx++)
            {
                StreamDirectoryInfo SubDirectory = new StreamDirectoryInfo(Reader, this);
                NameToSubDirectory.Add(SubDirectory.Name, SubDirectory);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Name">Name of the directory</param>
 /// <param name="ParentDirectory">Parent directory</param>
 public StreamDirectoryInfo(string Name, StreamDirectoryInfo ParentDirectory)
 {
     this.Name            = Name;
     this.ParentDirectory = ParentDirectory;
 }
        void MergeDirectory(WorkspaceDirectoryInfo WorkspaceDir, WorkspaceDirectoryInfo NewWorkspaceDir, StreamDirectoryInfo StreamDir, ThreadPoolWorkQueue Queue)
        {
            // Make sure the directory exists
            Directory.CreateDirectory(WorkspaceDir.GetFullName());

            // Update all the subdirectories
            foreach (StreamDirectoryInfo StreamSubDir in StreamDir.NameToSubDirectory.Values)
            {
                WorkspaceDirectoryInfo WorkspaceSubDir;
                if (WorkspaceDir.NameToSubDirectory.TryGetValue(StreamSubDir.Name, out WorkspaceSubDir))
                {
                    MergeSubDirectory(WorkspaceSubDir, StreamSubDir, NewWorkspaceDir, Queue);
                }
                else
                {
                    AddSubDirectory(NewWorkspaceDir, StreamSubDir, Queue);
                }
            }

            // Move files into this folder
            foreach (StreamFileInfo StreamFile in StreamDir.NameToFile.Values)
            {
                WorkspaceFileInfo WorkspaceFile;
                if (WorkspaceDir.NameToFile.TryGetValue(StreamFile.Name, out WorkspaceFile))
                {
                    NewWorkspaceDir.NameToFile.Add(WorkspaceFile.Name, WorkspaceFile);
                }
                else
                {
                    AddFile(NewWorkspaceDir, StreamFile);
                }
            }
        }
Beispiel #10
0
        void Merge(WorkspaceDirectoryInfo WorkspaceDir, WorkspaceDirectoryInfo NewWorkspaceDir, StreamDirectoryInfo StreamDir, ThreadPoolWorkQueue Queue)
        {
            // Update all the subdirectories
            foreach (WorkspaceDirectoryInfo WorkspaceSubDir in WorkspaceDir.NameToSubDirectory.Values)
            {
                StreamDirectoryInfo StreamSubDir;
                if (StreamDir.NameToSubDirectory.TryGetValue(WorkspaceSubDir.Name, out StreamSubDir))
                {
                    MergeSubDirectory(NewWorkspaceDir, WorkspaceSubDir, StreamSubDir, Queue);
                }
                else
                {
                    RemoveDirectory(WorkspaceSubDir, Queue);
                }
            }

            // Update the staged files
            foreach (WorkspaceFileInfo WorkspaceFile in WorkspaceDir.NameToFile.Values)
            {
                StreamFileInfo StreamFile;
                if (StreamDir != null && StreamDir.NameToFile.TryGetValue(WorkspaceFile.Name, out StreamFile) && StreamFile.ContentId.Equals(WorkspaceFile.ContentId))
                {
                    NewWorkspaceDir.NameToFile.Add(WorkspaceFile.Name, WorkspaceFile);
                }
                else
                {
                    RemoveFile(WorkspaceFile);
                }
            }
        }