1
Vote

Bug found in UpdateSyncIfItemHashChanged()

description

This bug is in CompoundRepository.cs::UpdateSyncIfItemHashChanged(). The call to update the repository is using the old sync value which means that the wrong metadata for an updated item is retained.
          private Sync UpdateSyncIfItemHashChanged(IXmlItem item, Sync sync)
          {
                 // TODO: check if this is correct.
                 if (item.Tag.ToString() != sync.Tag.ToString())
                 {
                       Tracer.TraceData(this, TraceEventType.Verbose, "Updating Sync for Item with ID {0} - Original Tag {1} / Current Tag {2}", sync.Id, sync.Tag, item.Tag);

                       Sync updated = Behaviors.Update(sync,
                              DeviceAuthor.Current,
                              DateTime.Now, sync.Deleted);
// HERE******
                       sync.Tag = item.Tag;
// HERE******
                       syncRepo.Save(sync);

                       return updated;
                 }

                 return sync;
          }
Proposed Solution: Change the highlighted ‘sync’ references to ‘updated’.

comments