Microsoft.HockeyApp.Channel.Storage.DeleteObsoleteFiles C# (CSharp) Méthode

DeleteObsoleteFiles() private méthode

Enqueue is saving a transmission to a tmp file and after a successful write operation it renames it to a trn file. A file without a trn extension is ignored by Storage.Peek(), so if a process is taken down before rename happens it will stay on the disk forever. This method deletes files with the tmp extension that exists on disk for more than 5 minutes.
private DeleteObsoleteFiles ( ) : void
Résultat void
        private void DeleteObsoleteFiles()
        {
            try
            {
                IEnumerable<FileInfo> files = this.GetFiles("*.tmp");
                foreach (FileInfo file in files)
                {
                    // if the file is older then a minute - delete it.
                    if (DateTime.UtcNow - file.CreationTimeUtc >= TimeSpan.FromMinutes(5))
                    {
                        file.Delete();
                    }
                }
            }
            catch (Exception e)
            {
                CoreEventSource.Log.LogVerbose("Failed to delete tmp files. Exception: " + e);
            }
        }
    }