Skip to content

Commit

Permalink
Fixed unneeded template files removal after copying them over to dest…
Browse files Browse the repository at this point in the history
…ination. Closes #59.

The problem was when a hidden file was found within a hidden directory (such as .svn with it's contents). In such case the directory was removed before processing the file and when the file was being removed, it no longer existed, so an error was reported. This is properly handled now, thanks to "BloodDragon" for pointing it out.
  • Loading branch information
tomaz committed Jan 31, 2011
1 parent 3f49dc9 commit d3b5b4f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Generating/GBOutputGenerator.m
Expand Up @@ -88,7 +88,7 @@ - (BOOL)copyTemplateFilesToOutputPath:(NSError **)error {
return NO;
}

// Remove all ignored files and special template items from output. First enumerate all files. If this fails, report success; this step is only used to verscleanup the destination, we should still have valid output if these files are kept there.
// Remove all ignored files and special template items from output. First enumerate all files. If this fails, report success; this step is only used to verscleanup the destination, we should still have valid output if these files are kept there. Note that we need to test for existing file before removing as it could happen file's parent dir was removed already in previous iterations so the file or subdir doesn't exist anymore - see https://github.com/tomaz/appledoc/issues#issue/59 for details.
GBLogDebug(@"Removing temporary files from '%@'...", destUserPath);
NSArray *items = [self.fileManager subpathsOfDirectoryAtPath:destPath error:error];
if (!items) {
Expand All @@ -110,7 +110,7 @@ - (BOOL)copyTemplateFilesToOutputPath:(NSError **)error {

if (delete) {
NSString *fullpath = [destPath stringByAppendingPathComponent:path];
if (![self.fileManager removeItemAtPath:fullpath error:error]) {
if ([self.fileManager fileExistsAtPath:fullpath] && ![self.fileManager removeItemAtPath:fullpath error:error]) {
GBLogWarn(@"Can't clean leftover '%@' from '%@'.", path, destUserPath);
}
}
Expand Down

0 comments on commit d3b5b4f

Please sign in to comment.