Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Auto-sync timestamp doesn't get updated
LemurTech
#1 Posted : Tuesday, 22 November 2011 1:30:07 PM(UTC)
Rank: Member

Joined: 22/11/2011(UTC)
Posts: 4
Location: Ashland, OR

Hi and kudos for a great app!

I have upgraded to 2.6 and it seems that the auto-sync completion timestamp is not getting updated at the end of end auto-sync. This results in the sync running again, after a brief pause!

I would use a web services call to run the sync on a schedule, except I don't really understand how to make that happen.

Matthew
Roger Martin
#2 Posted : Tuesday, 22 November 2011 1:51:17 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

I just tested the auto-sync on my own copy of 2.6, and it is working. Note that two entries are written to the event log during an auto-sync - one when it starts; the other when it completes. Do you see both of them (look in the error log in the site admin area).
Roger Martin
Creator and Lead Developer of Gallery Server Pro
LemurTech
#3 Posted : Tuesday, 22 November 2011 5:16:31 PM(UTC)
Rank: Member

Joined: 22/11/2011(UTC)
Posts: 4
Location: Ashland, OR

Thanks, Roger. I do see both log entries. Nevertheless, the autosync kicks in after the previous one has ended. I have log entries that show it starting up after about one minute, and others that show it starting at about 5 minutes. I have the sync scheduled for ever 720 minutes. Each sync is only taking about 10 minutes to complete.
LemurTech
#4 Posted : Monday, 28 November 2011 1:48:36 PM(UTC)
Rank: Member

Joined: 22/11/2011(UTC)
Posts: 4
Location: Ashland, OR

Sorry to be a pain, but I'm not sure what the way out of this is.

There was a point just before the upgrade to 2.6 where I went into the DB table and modified the timestamp so that the auto-sync would time from the middle of the night; I changed nothing except the setting value. But then I quickly decided to revise the auto-sync interval. It was only after the upgrade that I discovered that the timestamp wasn't updating.

Is there anything you can think of that would stop the timestamp from being updated?

Matthew
Roger Martin
#5 Posted : Monday, 28 November 2011 2:49:48 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Sorry for the delay in responding, but I was running a test. I enabled autosync on the demo site to run every 3 hours. There are over 60,000 media files, and it took about 4 minutes to run a sync. I watched it over the last few days, and it worked like a charm.

I also looked at the source code (see below) and noticed that if an error occurs during the sync, a log entry will be made with the error details but you will still get a *subsequent* log entry that says it successfully completed. So I would look at the log between the start and finish notifications to see if there are any entries.

Code:
/// <summary>
/// Perform a synchronize according to the specified <paramref name="syncSettingsObject" />.
/// When complete, update the <see cref="IGallerySettings.LastAutoSync" /> property to the current date/time and persist
/// to the data store. The <paramref name="syncSettingsObject" /> is specified as <see cref="Object" /> so that this method can 
/// be invoked on a separate thread using <see cref="System.Threading.Thread" />. Any exceptions that occur during the
/// sync are caught and logged to the event log. NOTE: This method does not perform any security checks; the calling
/// code must ensure the requesting user is authorized to run the sync.
/// </summary>
/// <param name="syncSettingsObject">The synchronize settings object. It must be of type <see cref="SynchronizeSettingsEntity" />.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="syncSettingsObject" /> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="syncSettingsObject" /> is not of type 
/// <see cref="SynchronizeSettingsEntity" />.</exception>
public static void Synchronize(object syncSettingsObject)
{
 if (syncSettingsObject == null)
  throw new ArgumentNullException("syncSettingsObject");

 SynchronizeSettingsEntity syncSettings = syncSettingsObject as SynchronizeSettingsEntity;

 if (syncSettings == null)
 {
  throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, "The parameter must be an instance of SynchronizeSettingsEntity. Instead, it was {0}.", syncSettingsObject.GetType()));
 }

 IAlbum album = syncSettings.AlbumToSynchronize;

 AppErrorController.LogEvent(String.Format(CultureInfo.CurrentCulture, "INFO (not an error): {0} synchronization of album '{1}' (ID {2}) and all child albums has started.", syncSettings.SyncInitiator, album.Title, album.Id), album.GalleryId);

 try
 {
  SynchronizationManager synchMgr = new SynchronizationManager(album.GalleryId);

  synchMgr.IsRecursive = syncSettings.IsRecursive;
  synchMgr.RebuildThumbnail = syncSettings.RebuildThumbnails;
  synchMgr.RebuildOptimized = syncSettings.RebuildOptimized;
  synchMgr.RegenerateMetadata = syncSettings.RegenerateMetadata;

  synchMgr.Synchronize(Guid.NewGuid().ToString(), album, "Admin");

  if (syncSettings.SyncInitiator == SyncInitiator.AutoSync)
  {
   // Update the date/time of this auto-sync and save to data store.
   IGallerySettings gallerySettings = Factory.LoadGallerySetting(album.GalleryId, true);
   gallerySettings.LastAutoSync = DateTime.Now;
   gallerySettings.Save(false);

   // The above Save() only updated the database; now we need to update the in-memory copy of the settings.
   // We have to do this instead of simply calling gallerySettings.Save(true) because that overload causes the
   // gallery settings to be cleared and reloaded, and the reloading portion done by the AddMembershipDataToGallerySettings
   // function fails in DotNetNuke because there isn't a HttpContext.Current instance at this moment (because this code is
   // run on a separate thread).
   IGallerySettings gallerySettingsReadOnly = Factory.LoadGallerySetting(album.GalleryId, false);
   gallerySettingsReadOnly.LastAutoSync = gallerySettings.LastAutoSync;
  }
 }
 catch (Exception ex)
 {
  AppErrorController.LogError(ex, album.GalleryId);
 }

 AppErrorController.LogEvent(String.Format(CultureInfo.CurrentCulture, "INFO (not an error): {0} synchronization of album '{1}' (ID {2}) and all child albums is complete.", syncSettings.SyncInitiator, album.Title, album.Id), album.GalleryId);
}

Roger Martin
Creator and Lead Developer of Gallery Server Pro
LemurTech
#6 Posted : Monday, 28 November 2011 6:45:35 PM(UTC)
Rank: Member

Joined: 22/11/2011(UTC)
Posts: 4
Location: Ashland, OR

Ok, with your hint I tracked this down to a .tif file that couldn't be processed. Once I got rid of that, the sync finished just fine. If it's any help to you, here's the error that was appearing just after the .tif problem.

Thanks for your help!

Matthew
LemurTech attached the following image(s):
LemurTech attached the following image(s): 2011-11-28 1-56-17 PM.png
Roger Martin
#7 Posted : Monday, 28 November 2011 8:57:12 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Thanks for posting the stack trace. With that info, I was able to modify the source code to silently handle this kind of issue in the future. The fix will be included in the first post-2.6.0 release.

I also recognize there is some room for improvement in the event log message (it shouldn't report a success when it actually failed).
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Rss Feed  Atom Feed
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.