[banshee/art-caching] Regoranize some code
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee/art-caching] Regoranize some code
- Date: Fri, 4 Dec 2009 02:08:26 +0000 (UTC)
commit dcef0c7ff1ca2d8cb6a8675197f6e2faa909fb5e
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu Dec 3 18:04:01 2009 -0800
Regoranize some code
.../Banshee.Collection.Gui/ArtworkManager.cs | 96 ++++++++++----------
1 files changed, 50 insertions(+), 46 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
index 8ba3dd0..c91d30f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
@@ -79,52 +79,6 @@ namespace Banshee.Collection.Gui
}
}
- const int CUR_VERSION = 2;
- private void MigrateCacheDir ()
- {
- int version = CacheVersion;
- if (version == CUR_VERSION) {
- return;
- }
-
- var root_path = CoverArtSpec.RootPath;
-
- if (version < 1) {
- string legacy_artwork_path = Paths.Combine (Paths.LegacyApplicationData, "covers");
-
- if (!Directory.Exists (root_path)) {
- Directory.Create (CoverArtSpec.RootPath);
-
- if (Directory.Exists (legacy_artwork_path)) {
- Directory.Move (new SafeUri (legacy_artwork_path), new SafeUri (root_path));
- }
- }
-
- if (Directory.Exists (legacy_artwork_path)) {
- Log.InformationFormat ("Deleting old (Banshee < 1.0) artwork cache directory {0}", legacy_artwork_path);
- Directory.Delete (legacy_artwork_path, true);
- }
- }
-
- if (version < 2) {
- int deleted = 0;
- foreach (string dir in Directory.GetDirectories (root_path)) {
- int size;
- string dirname = System.IO.Path.GetFileName (dir);
- if (Int32.TryParse (dirname, out size) && !IsCachedSize (size)) {
- Directory.Delete (dir, true);
- deleted++;
- }
- }
-
- if (deleted > 0) {
- Log.InformationFormat ("Deleted {0} extraneous album-art cache directories", deleted);
- }
- }
-
- CacheVersion = CUR_VERSION;
- }
-
public Cairo.ImageSurface LookupSurface (string id)
{
return LookupScaleSurface (id, 0);
@@ -282,6 +236,54 @@ namespace Banshee.Collection.Gui
get { return "ArtworkManager"; }
}
+#region Cache Directory Versioning/Migration
+
+ private const int CUR_VERSION = 2;
+ private void MigrateCacheDir ()
+ {
+ int version = CacheVersion;
+ if (version == CUR_VERSION) {
+ return;
+ }
+
+ var root_path = CoverArtSpec.RootPath;
+
+ if (version < 1) {
+ string legacy_artwork_path = Paths.Combine (Paths.LegacyApplicationData, "covers");
+
+ if (!Directory.Exists (root_path)) {
+ Directory.Create (CoverArtSpec.RootPath);
+
+ if (Directory.Exists (legacy_artwork_path)) {
+ Directory.Move (new SafeUri (legacy_artwork_path), new SafeUri (root_path));
+ }
+ }
+
+ if (Directory.Exists (legacy_artwork_path)) {
+ Log.InformationFormat ("Deleting old (Banshee < 1.0) artwork cache directory {0}", legacy_artwork_path);
+ Directory.Delete (legacy_artwork_path, true);
+ }
+ }
+
+ if (version < 2) {
+ int deleted = 0;
+ foreach (string dir in Directory.GetDirectories (root_path)) {
+ int size;
+ string dirname = System.IO.Path.GetFileName (dir);
+ if (Int32.TryParse (dirname, out size) && !IsCachedSize (size)) {
+ Directory.Delete (dir, true);
+ deleted++;
+ }
+ }
+
+ if (deleted > 0) {
+ Log.InformationFormat ("Deleted {0} extraneous album-art cache directories", deleted);
+ }
+ }
+
+ CacheVersion = CUR_VERSION;
+ }
+
private static SafeUri cache_version_file = new SafeUri (Paths.Combine (CoverArtSpec.RootPath, ".cache_version"));
private static int CacheVersion {
get {
@@ -303,5 +305,7 @@ namespace Banshee.Collection.Gui
}
}
+#endregion
+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]