Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Conversation

ronaldbarendse
Copy link
Collaborator

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practise as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This fixes issue https://github.com/JimBobSquarePants/ImageProcessor/issues/794 by catching exceptions thrown while enumerating files from directories that are deleted while the cache trimming is executed (e.g. by another server running a concurrent cache trimming job or manually deleting the directory).

Copy link
Owner

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for picking this one up.

@JimBobSquarePants JimBobSquarePants merged commit f56ce58 into JimBobSquarePants:develop-v2 Apr 2, 2020
@ronaldbarendse ronaldbarendse deleted the fix-cachetrimmer branch April 3, 2020 12:15
@ronaldbarendse
Copy link
Collaborator Author

Looks like RecursivelyDeleteEmptyDirectories() still throws DirectoryNotFoundExceptions, as the directory is deleted if it has no subdirectories/files and then tries to get its parent folder:

// If the directory is empty of files delete it to remove the FCN.
if (Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly).Length == 0
&& Directory.GetDirectories(directory, "*", SearchOption.TopDirectoryOnly).Length == 0)
{
Directory.Delete(directory);
}
this.RecursivelyDeleteEmptyDirectories(Directory.GetParent(directory).FullName, root, token);

I think this whole method can be removed, as the cache trimmer already reverses all paths and therefore could do a single check (without recursively traversing to parent directories).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IO Errors with CacheTrimmer in Scaled Environment
2 participants