Esempio n. 1
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Get the list of symbol file name patterns from the platform.
            Platform TargetPlatform = Platform.GetPlatform(Parameters.Platform);

            string[] DirectoryStructure = TargetPlatform.SymbolServerDirectoryStructure;
            if (DirectoryStructure == null)
            {
                CommandUtils.LogError("Platform does not specify the symbol server structure. Cannot age the symbol server.");
                return(false);
            }

            string Filter = string.IsNullOrWhiteSpace(Parameters.Filter)
                ? string.Empty
                : Parameters.Filter.Trim();

            // Get the time at which to expire files
            DateTime ExpireTimeUtc = DateTime.UtcNow - TimeSpan.FromDays(Parameters.Days);

            CommandUtils.Log("Expiring all files before {0}...", ExpireTimeUtc);

            // Scan the store directory and delete old symbol files
            DirectoryReference SymbolServerDirectory = ResolveDirectory(Parameters.StoreDir);

            LockFile.TakeLock(SymbolServerDirectory, TimeSpan.FromMinutes(15), () =>
            {
                RecurseDirectory(ExpireTimeUtc, new DirectoryInfo(SymbolServerDirectory.FullName), DirectoryStructure, 0, Filter);
            });

            return(true);
        }