message: Can now remove unused versions of installed mods from cache
diff: @@ -4,6 +4,8 @@ import * as path from 'path';
  import ProfileModList from './ProfileModList';
  import R2Error from '../../model/errors/R2Error';
  import PathResolver from '../manager/PathResolver';
  +import ManifestV2 from '../../model/ManifestV2';
  +import VersionNumber from '../../model/VersionNumber';
  export default class CacheUtil {
  @@ -18,7 +20,7 @@ export default class CacheUtil {
  }
  });
  - const activeModSet = new Set<string>();
  + const activeModSet = new Set<ManifestV2>();
  profiles.forEach(value => {
  const profile = new Profile(value);
  const modList = ProfileModList.getModList(profile);
  @@ -26,17 +28,26 @@ export default class CacheUtil {
  return;
  }
  modList.forEach(value => {
  - activeModSet.add(value.getName());
  + activeModSet.add(value);
  });
  });
  const cacheDirectory = path.join(PathResolver.ROOT, "mods", "cache");
  fs.readdirSync(cacheDirectory).forEach(folder => {
  if (fs.lstatSync(path.join(cacheDirectory, folder)).isDirectory()) {
  - if (!activeModSet.has(folder)) {
  + if (this.hasNoVersions(folder, activeModSet)) {
  // TODO: 310 - Override this with FileUtil usage.
  this.emptyDirectory(path.join(cacheDirectory, folder));
  fs.rmdirSync(path.join(cacheDirectory, folder));
  + } else {
  + const versions = this.getVersionsInstalled(folder, activeModSet);
  + fs.readdirSync(path.join(cacheDirectory, folder)).forEach(versionFolder => {
  + const matchingVersion = versions.find(value => value.toString() === versionFolder);
  + if (matchingVersion === undefined) {
  + this.emptyDirectory(path.join(cacheDirectory, folder, versionFolder));
  + fs.rmdirSync(path.join(cacheDirectory, folder, versionFolder));
  + }
  + })
  }
  }
  })
  @@ -45,6 +56,15 @@ export default class CacheUtil {
  new Profile(currentProfileName);
  }
  + private static hasNoVersions(modName: string, mods: Set<ManifestV2>): boolean {
  + return Array.from(mods).filter(value => value.getName() === modName).length === 0;
  + }
  +
  + public static getVersionsInstalled(modName: string, mods: Set<ManifestV2>): VersionNumber[] {
  + return Array.from(mods).filter(value => value.getName() === modName)
  + .map(value => value.getVersionNumber());
  + }
  +
  private static emptyDirectory(dir: string) {
  const files = fs.readdirSync(dir);
  files.forEach(filename => {
  