Skip to content

Commit

Permalink
Add loads more logging
Browse files Browse the repository at this point in the history
Relates to #256
  • Loading branch information
canton7 committed Apr 26, 2016
1 parent 9dd61bf commit 66416b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/SyncTrayzor/Services/DirectoryWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,25 @@ public override void OnPathChanged(string subPath, bool pathExists, bool isDirec
{
base.OnPathChanged(subPath, pathExists, isDirectory);

logger.Debug($"OnPathChanged: subPath={subPath} pathExists={pathExists} isDirectory={isDirectory}");

if (this.OnPreviewDirectoryChanged(subPath, pathExists))
{
logger.Debug("OnPathChanged: Ignoring change because PreviewDirectoryChanged was cancelled");
return;
}

this.backoffTimer.Stop();
lock (this.currentNotifyingSubPathLock)
{
logger.Debug($"OnPathChanged: currentNotifyingSubPath was {this.currentNotifyingSubPath}");

if (this.currentNotifyingSubPath == null)
this.currentNotifyingSubPath = subPath;
else
this.currentNotifyingSubPath = this.FindCommonPrefix(this.currentNotifyingSubPath, subPath);

logger.Debug($"OnPathChanged: currentNotifyingSubPath is now {this.currentNotifyingSubPath}");
}

this.backoffTimer.Start();
Expand Down
13 changes: 13 additions & 0 deletions src/SyncTrayzor/Services/FileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ private void OnRenamed(object source, RenamedEventArgs e)

private void RecordPathChange(string path, bool pathExists)
{
logger.Debug($"RecordPathChange: path={path} pathExists={pathExists}");

// First, we need to convert to a long path, just in case anyone's using the short path
// We can't do this if we don't expect the file to exist any more...
// There's also a chance that the file no longer exists. Catch that exception.
Expand All @@ -245,17 +247,28 @@ private void RecordPathChange(string path, bool pathExists)
if (pathExists)
path = this.GetLongPathName(path);

logger.Debug($"RecordPathChanged: long path name = {path}");

if (!path.StartsWith(this.Directory))
{
logger.Warn($"Ignoring path {path} as it does not start with {this.Directory}");
return;
}

var subPath = path.Substring(this.Directory.Length);

logger.Debug($"RecordPathChanged: subPath={subPath}");

// If it contains a tilde, then it's a short path that squeezed through GetLongPath above
// (e.g. because it was a deletion), then strip it back to the first component without an ~
subPath = this.StripShortPathSegments(subPath);

logger.Debug($"RecordPathChanged: subPath afer stripping short path segments={subPath}");

bool isDirectory = !this.filesystem.FileExists(path);

logger.Debug($"RecordPathChanged: isDirectory={isDirectory}");

this.OnPathChanged(subPath, pathExists, isDirectory);
}

Expand Down

0 comments on commit 66416b2

Please sign in to comment.