Esempio n. 1
0
        internal void Go()
        {
            while (_queue.Any())
            {
                lock (this)
                {
                    if (!_queue.Any())
                    {
                        return;
                    }
                    var current = _queue.First();
                    if (!current.Key.Directory.Exists)
                    {
                        CreateDirectoryTree(current.Value.Directory, current.Key.Directory);
                    }
                    using (Stream src = current.Value.OpenRead())
                        using (Stream dest = current.Key.Exists
                                         ? current.Key.Open(FileMode.Truncate, FileAccess.ReadWrite)
                                         : current.Key.Create())
                            src.CopyTo(dest);


                    // set the attributes and file timestamps (and ACLs if it's ntfs...)
                    current.Key.Attributes = current.Value.Attributes;
                    if (current.Key.FileSystem is NtfsFileSystem)
                    {
                        var D = (NtfsFileSystem)current.Key.FileSystem;
                        var S = (NtfsFileSystem)current.Value.FileSystem;
                        D.SetSecurity(current.Key.FullName, S.GetSecurity(current.Value.FullName));

                        D.SetFileStandardInformation(current.Key.FullName,
                                                     S.GetFileStandardInformation(current.Value.FullName));
                    }
                    else
                    {
                        current.Key.CreationTimeUtc   = current.Value.CreationTimeUtc;
                        current.Key.LastWriteTimeUtc  = current.Value.LastWriteTimeUtc;
                        current.Key.LastAccessTimeUtc = current.Value.LastAccessTimeUtc;
                    }


                    _queue.Remove(current.Key);
                }
            }
        }
Esempio n. 2
0
        public static void StandBy(string projectName)
        {
            if (projectName == null)
            {
                throw new ArgumentException("ProjectName cannot be null.");
            }
            if (!Projects.ContainsKey(projectName))
            {
                throw new ArgumentException("Project not found: " + projectName);
            }

            Waiting[projectName] = Waiting[projectName] ?? new Timer(o =>
            {
                Waiting[projectName].Dispose();
                Waiting.Remove(projectName);
                Trigger(projectName);
            });
            Waiting[projectName].Change(MasterConfig.PreTriggerWait, Timeout.Infinite);
        }