Skip to content

Commit

Permalink
Added ckan clean to empty the cache directory.
Browse files Browse the repository at this point in the history
Part of #25.
  • Loading branch information
pjf committed Oct 4, 2014
1 parent ceef929 commit d30e6ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CKAN/CKAN/KSP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ public static void init() {
}
}

public static void CleanCache() {

log.Debug ("Cleaning cahce directory");

string[] files = Directory.GetFiles (downloadCacheDir (), "*", SearchOption.AllDirectories);

foreach (string file in files) {

if (FileSystem.IsDirectory (file)) {
log.DebugFormat ("Skipping directory: {0}", file);
continue;
}

log.DebugFormat ("Deleting {0}", file);
File.Delete (file);
}

return;
}

public static void scanGameData() {

// TODO: Get rid of magic paths!
Expand Down
12 changes: 12 additions & 0 deletions CKAN/CKAN/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public static int Main (string[] args) {
case "remove":
return remove ((RemoveOptions)cmdline.options);

case "clean":
return clean ();

default :
Console.WriteLine ("Unknown command, try --help");
return EXIT_BADOPT;
Expand Down Expand Up @@ -145,6 +148,11 @@ public static int remove(RemoveOptions options) {
return EXIT_OK;
}

static int clean() {
KSP.CleanCache ();
return EXIT_OK;
}

public static int install(InstallOptions options) {

// If we have a zipfile, use it.
Expand Down Expand Up @@ -247,6 +255,9 @@ class Actions {
[VerbOption("show", HelpText = "Show information about a mod")]
public ShowOptions Show { get; set; }

[VerbOption("clean", HelpText = "Clean away downloaded files from the cache")]
public CleanOptions Clean { get; set; }

[VerbOption("version", HelpText = "Show the version of the CKAN client being used.")]
public VersionOptions Version { get; set; }

Expand Down Expand Up @@ -278,6 +289,7 @@ class InstallOptions : CommonOptions {
class ScanOptions : CommonOptions { }
class ListOptions : CommonOptions { }
class VersionOptions : CommonOptions { }
class CleanOptions : CommonOptions { }

class RemoveOptions : CommonOptions {
[ValueOption(0)]
Expand Down

0 comments on commit d30e6ba

Please sign in to comment.