public static void AddToQueue(string filepath) { if (FileHashStore.HasChangedOrIsNew(filepath)) { Queue.Add(filepath); } }
private static void ProcessQueue() { for (int i = _cache.Count - 1; i >= 0; i--) { var entry = _cache.ElementAt(i); // The file should be 1 second old before we start processing if (entry.Value > DateTime.Now.AddSeconds(-1)) { continue; } if (!_store.HasChangedOrIsNew(entry.Key)) { _cache.Remove(entry.Key); continue; } try { Minify(entry.Key); _store.Save(entry.Key); _cache.Remove(entry.Key); } catch (IOException) { // Do nothing, let's try again next time } catch { _cache.Remove(entry.Key); } } }
private static void ProcessQueue() { if (_isProcessing) { return; } _isProcessing = true; int length = _cache.Count - 1; for (int i = length; i >= 0; i--) { if (_cache.Count < i) { continue; } var entry = _cache.ElementAt(i); try { // The file should be a second old before we start processing if (entry.Value > DateTime.Now.AddSeconds(-2)) { continue; } if (!_store.HasChangedOrIsNew(entry.Key)) { _cache.Remove(entry.Key); continue; } _compressor.CompressFile(entry.Key); _cache.Remove(entry.Key); } catch (IOException) { // do nothing. We'll try again } catch { _cache.Remove(entry.Key); } } _isProcessing = false; }
/// <summary> /// Determine whether to skip the compression of this file. This method determines whether the user has /// sent the force parameter, and whether the hash entry is new or has changed since last run. If either are false, then the /// file should be processed/compressed. /// </summary> /// <param name="entryKey">The key of the file store hash to check</param> private static bool ShouldSkipFileEntry(string entryKey) { return(_shouldForceOptimizeAllFiles == false && _store.HasChangedOrIsNew(entryKey) == false); }