/// <summary> /// Initializes a new instance of the <see cref="Repository"/> class. /// </summary> /// <param name="localPath"></param> /// <param name="container"></param> public Repository(NPath localPath, ICacheContainer container) { Guard.ArgumentNotNull(localPath, nameof(localPath)); LocalPath = localPath; cacheUpdateEvents = new Dictionary <CacheType, Action <CacheUpdateEvent> > { { CacheType.Branches, cacheUpdateEvent => { LocalBranchListChanged?.Invoke(cacheUpdateEvent); RemoteBranchListChanged?.Invoke(cacheUpdateEvent); LocalAndRemoteBranchListChanged?.Invoke(cacheUpdateEvent); } }, { CacheType.GitAheadBehind, c => TrackingStatusChanged?.Invoke(c) }, { CacheType.GitLocks, c => LocksChanged?.Invoke(c) }, { CacheType.GitLog, c => LogChanged?.Invoke(c) }, { CacheType.GitFileLog, c => FileLogChanged?.Invoke(c) }, { CacheType.GitStatus, c => StatusEntriesChanged?.Invoke(c) }, { CacheType.GitUser, cacheUpdateEvent => { } }, { CacheType.RepositoryInfo, cacheUpdateEvent => { CurrentBranchChanged?.Invoke(cacheUpdateEvent); CurrentRemoteChanged?.Invoke(cacheUpdateEvent); CurrentBranchAndRemoteChanged?.Invoke(cacheUpdateEvent); } }, }; cacheContainer = container; cacheContainer.CacheInvalidated += CacheHasBeenInvalidated; cacheContainer.CacheUpdated += (cacheType, offset) => { cacheUpdateEvents[cacheType](new CacheUpdateEvent(cacheType, offset)); }; }
/// <summary> /// Puts the specified file in the File Log and saves to the config file /// </summary> public void putFile(SyncQueueItem file) { Log.Write(l.Debug, "Putting file {0} to log", file.NewCommonPath); if (Contains(file.NewCommonPath)) { Remove(file.NewCommonPath); } Files.Add(new FileLogItem { CommonPath = file.NewCommonPath, Local = file.SyncTo == SyncTo.Remote ? file.Item.LastWriteTime : System.IO.File.GetLastWriteTime(file.LocalPath), Remote = controller.Client.GetLwtOf(file.NewCommonPath) }); FileLogChanged.SafeInvoke(null, EventArgs.Empty); Settings.SaveProfile(); }