Author: jwilcox
Date: 2006-07-18 10:08:29 -0400 (Tue, 18 Jul 2006)
New Revision: 62702
Modified:
trunk/ipod-sharp/ChangeLog
trunk/ipod-sharp/src/Photo.cs
trunk/ipod-sharp/src/PhotoDatabase.cs
trunk/ipod-sharp/src/TrackDatabase.cs
Log:
2006-07-18 James Willcox <[EMAIL PROTECTED]>
* src/Photo.cs: add an internal CurrentFullSizeFileName property
* src/PhotoDatabase.cs: make sure old photos are removed
Modified: trunk/ipod-sharp/ChangeLog
===================================================================
--- trunk/ipod-sharp/ChangeLog 2006-07-18 12:07:38 UTC (rev 62701)
+++ trunk/ipod-sharp/ChangeLog 2006-07-18 14:08:29 UTC (rev 62702)
@@ -1,3 +1,8 @@
+2006-07-18 James Willcox <[EMAIL PROTECTED]>
+
+ * src/Photo.cs: add an internal CurrentFullSizeFileName property
+ * src/PhotoDatabase.cs: make sure old photos are removed
+
2006-07-06 Aaron Bockover <[EMAIL PROTECTED]>
* configure.ac: Require libipoddevice 0.4.6+
Modified: trunk/ipod-sharp/src/Photo.cs
===================================================================
--- trunk/ipod-sharp/src/Photo.cs 2006-07-18 12:07:38 UTC (rev 62701)
+++ trunk/ipod-sharp/src/Photo.cs 2006-07-18 14:08:29 UTC (rev 62702)
@@ -11,7 +11,7 @@
private PhotoDatabase db;
private List<Thumbnail> thumbnails = new List<Thumbnail> ();
private string fullSizeFile;
- private bool needsCopy = false;
+ private bool dirty = false;
internal int Id {
get { return item.Id; }
@@ -25,8 +25,8 @@
get { return db; }
}
- internal bool NeedsCopy {
- get { return needsCopy; }
+ internal bool Dirty {
+ get { return dirty; }
}
public DateTime OriginalDate {
@@ -51,18 +51,26 @@
public string FullSizeFileName {
get {
- if (fullSizeFile != null) {
+ if (dirty) {
return fullSizeFile;
- } else if (item.FullName == null) {
- return null;
} else {
- return db.GetFilesystemPath (item.FullName.FileName);
+ return CurrentFullSizeFileName;
}
} set {
fullSizeFile = value;
- needsCopy = true;
+ dirty = true;
}
}
+
+ internal string CurrentFullSizeFileName {
+ get {
+ if (item.FullName == null || item.FullName.FileName == null)
+ return null;
+
+ return db.GetFilesystemPath (item.FullName.FileName);
+ }
+ }
+
internal Photo (ImageItemRecord item, PhotoDatabase db) {
this.item = item;
@@ -74,9 +82,13 @@
}
internal void SetPodFileName () {
- item.FullName.FileName = String.Format (":Full
Resolution:{0}:{1}:{2}:{3}", OriginalDate.Year,
- OriginalDate.Month,
OriginalDate.Day,
- Path.GetFileName
(fullSizeFile));
+ if (fullSizeFile != null) {
+ item.FullName.FileName = String.Format (":Full
Resolution:{0}:{1}:{2}:{3}", OriginalDate.Year,
+ OriginalDate.Month,
OriginalDate.Day,
+ Path.GetFileName
(fullSizeFile));
+ } else {
+ item.FullName = null;
+ }
}
public Thumbnail CreateThumbnail () {
Modified: trunk/ipod-sharp/src/PhotoDatabase.cs
===================================================================
--- trunk/ipod-sharp/src/PhotoDatabase.cs 2006-07-18 12:07:38 UTC (rev
62701)
+++ trunk/ipod-sharp/src/PhotoDatabase.cs 2006-07-18 14:08:29 UTC (rev
62702)
@@ -766,6 +766,7 @@
public DateTime OriginalDate = DateTime.Now;
public DateTime DigitizedDate = DateTime.Now;
public int SourceImageSize;
+ public ImageNameRecord FullName;
public IList<ImageNameRecord> Names {
get {
@@ -784,8 +785,6 @@
return new ReadOnlyCollection<ImageNameRecord> (removedNames);
}
}
-
- public ImageNameRecord FullName;
public ImageItemRecord (bool isbe) : base (isbe) {
this.Name = "mhii";
@@ -1108,8 +1107,7 @@
List<Photo> dirtyPhotos = new List<Photo> ();
foreach (Photo photo in photos.Values) {
- if (photo.NeedsCopy) {
- photo.SetPodFileName ();
+ if (photo.Dirty) {
dirtyPhotos.Add (photo);
}
}
@@ -1122,7 +1120,19 @@
for (int i = 0; i < dirtyPhotos.Count; i++) {
if (SaveProgressChanged != null)
SaveProgressChanged (this, new PhotoSaveProgressArgs
((double) i / (double) dirtyPhotos.Count));
- CopyPhoto (dirtyPhotos[i]);
+ // delete old file if necessary
+ if (dirtyPhotos[i].CurrentFullSizeFileName != null &&
+ File.Exists (dirtyPhotos[i].CurrentFullSizeFileName)) {
+
+ File.Delete (dirtyPhotos[i].CurrentFullSizeFileName);
+ }
+
+ // set the new filename in the db
+ dirtyPhotos[i].SetPodFileName ();
+
+ // copy new file if necessary
+ if (dirtyPhotos[i].FullSizeFileName != null)
+ CopyPhoto (dirtyPhotos[i]);
}
if (SaveProgressChanged != null)
Modified: trunk/ipod-sharp/src/TrackDatabase.cs
===================================================================
--- trunk/ipod-sharp/src/TrackDatabase.cs 2006-07-18 12:07:38 UTC (rev
62701)
+++ trunk/ipod-sharp/src/TrackDatabase.cs 2006-07-18 14:08:29 UTC (rev
62702)
@@ -1911,11 +1911,11 @@
}
// Remove empty Music "F" directories
- DirectoryInfo music_dir = new DirectoryInfo (MusicBasePath);
- foreach (DirectoryInfo f_dir in music_dir.GetDirectories ()) {
+ DirectoryInfo musicDir = new DirectoryInfo (MusicBasePath);
+ foreach (DirectoryInfo fdir in musicDir.GetDirectories ()) {
try {
- if (f_dir.GetFiles ().Length == 0) {
- f_dir.Delete();
+ if (fdir.GetFiles ().Length == 0) {
+ fdir.Delete();
}
} catch {
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches