<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace MoviePicker.WebApp.Utilities
{
	public static class FileUtility
	{
		private const int MOVIE_EXPIRATION_DAYS = 7;
		//private const int SHARED_EXPIRATION_MINUTES = 5;
		private const int SHARED_EXPIRATION_MINUTES = 24 * 60;      // One day - may want to back this off later.
		private const string MOVIE_POSTER_PREFIX = "MoviePoster_";

		private static bool _isCleaningUp = false;
		private static object _isCleaningUpLock = new object();

		static FileUtility()
		{
			NextCleanUp = DateTime.Now;
		}

		static private DateTime NextCleanUp { get; set; }

		/// <summary>
		/// Every so often clean up the files.
		/// </summary>
		public static void CleanupFiles(string directoryPath)
		{
			if (ShouldCleanup() && directoryPath != null)
			{
				var directory = $"{Path.GetDirectoryName(directoryPath)}{Path.DirectorySeparatorChar}";

				// Loop through the MoviePosters.

				foreach (var file in Directory.GetFiles(directory, $"{MOVIE_POSTER_PREFIX}*"))
				{
					if (file.IndexOf(".temp") > 0)<commit_msg>Lengthed the time to purge the movie posters to 90 days.<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace MoviePicker.WebApp.Utilities
{
	public static class FileUtility
	{
		// Keep the movie posters around for a while, so they will fill out the film strip better.
		private const int MOVIE_EXPIRATION_DAYS = 90;

		//private const int SHARED_EXPIRATION_MINUTES = 5;
		private const int SHARED_EXPIRATION_MINUTES = 24 * 60;      // One day - may want to back this off later.
		private const string MOVIE_POSTER_PREFIX = "MoviePoster_";

		private static bool _isCleaningUp = false;
		private static object _isCleaningUpLock = new object();

		static FileUtility()
		{
			NextCleanUp = DateTime.Now;
		}

		static private DateTime NextCleanUp { get; set; }

		/// <summary>
		/// Every so often clean up the files.
		/// </summary>
		public static void CleanupFiles(string directoryPath)
		{
			if (ShouldCleanup() && directoryPath != null)
			{
				var directory = $"{Path.GetDirectoryName(directoryPath)}{Path.DirectorySeparatorChar}";

				// Loop through the MoviePosters.

				foreach (var file in Directory.GetFiles(directory, $"{MOVIE_POSTER_PREFIX}*"))
				{
					if (file.IndexOf(".temp") > 0)
{'fraction_non_alphanumeric': 0.09849119865884325, 'fraction_numerical': 0.007124895222129086, 'mean_word_length': 3.7931726907630523, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2755414', 'n_tokens_mistral': 846, 'n_tokens_neox': 732, 'n_words': 224}