Skip to content

Commit d95279f

Browse files
committed
Updating to newer APIs for divining latest mod times
Issue brotherbard#1 is based somewhere around PBGitRepositoryWatcher - possibly due to the creation of transient lock files.
1 parent bc9067a commit d95279f

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

PBGitRepositoryWatcher.m

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,29 @@ - (BOOL) _indexChanged {
7979
}
8080

8181
- (BOOL) _gitDirectoryChanged {
82-
BOOL isDirectory;
83-
NSDate *touchDate;
8482

85-
for (NSString *filename in [[NSFileManager defaultManager] directoryContentsAtPath:repository.fileURL.path]) {
86-
NSString *filepath = [repository.fileURL.path stringByAppendingPathComponent:filename];
87-
[[NSFileManager defaultManager] fileExistsAtPath:filepath isDirectory:&isDirectory];
83+
for (NSURL* fileURL in [[NSFileManager defaultManager] contentsOfDirectoryAtURL:repository.fileURL
84+
includingPropertiesForKeys:[NSArray arrayWithObject:NSURLContentModificationDateKey]
85+
options:0
86+
87+
error:nil])
88+
{
89+
BOOL isDirectory = NO;
90+
[[NSFileManager defaultManager] fileExistsAtPath:[fileURL path] isDirectory:&isDirectory];
8891
if (isDirectory)
8992
continue;
9093

91-
touchDate = [self _fileModificationDateAtPath:filepath];
92-
if ([gitDirTouchDate isLessThan:touchDate]) {
93-
gitDirTouchDate = touchDate;
94+
NSDate* modTime = nil;
95+
if (![fileURL getResourceValue:&modTime forKey:NSURLContentModificationDateKey error:nil])
96+
continue;
97+
98+
if (gitDirTouchDate == nil || [modTime compare:gitDirTouchDate] == NSOrderedDescending)
99+
{
100+
NSDate* newModTime = [[modTime laterDate:gitDirTouchDate] retain];
101+
if (gitDirTouchDate)
102+
[gitDirTouchDate release];
103+
104+
gitDirTouchDate = newModTime;
94105
return YES;
95106
}
96107
}

0 commit comments

Comments
 (0)