Ensure directories are always listed in deterministic order

macOS APIs have recently changed and do not return sorted entries for directories.
This commit is contained in:
Pierre-Olivier Latour
2019-01-03 15:59:28 -08:00
parent 71e972084c
commit c46a2ddb22
3 changed files with 12 additions and 12 deletions

View File

@@ -239,7 +239,7 @@ NS_ASSUME_NONNULL_END
}
NSError* error = nil;
NSArray* contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:absolutePath error:&error];
NSArray* contents = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:absolutePath error:&error] sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
if (contents == nil) {
return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed listing directory \"%@\"", relativePath];
}