mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Rename and document -updateAccessTimeOfItemAtRootURL:error:
This commit is contained in:
1 parent
599c3fb3c1
commit
ddb4262b7b
4 files changed
+19
-8
No files matched your search
Vendored
+13
-2
@@ -147,8 +147,19 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError **)error;
|
||||
|
||||
// TODO: document me. Note this does *not* attempt authorization
|
||||
- (BOOL)updateAccessTimeOfItemsRecursivelyAtURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error;
|
||||
/**
|
||||
* Updates the access time of an item at a specified root URL to the current time
|
||||
* @param targetURL A URL pointing to the target item whose access time to update to the current time.
|
||||
* This will be applied recursively if the item is a directory. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the target item's access times have been updated, otherwise NO along with a populated error object
|
||||
*
|
||||
* This method updates the access time of an item to the current time, ideal for letting the system know not to remove a file or directory when placing it
|
||||
* at a temporary directory.
|
||||
*
|
||||
* This is not an atomic operation. No authorization is performed for this method.
|
||||
*/
|
||||
- (BOOL)updateAccessTimeOfItemAtRootURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
* Releases Apple's quarantine extended attribute from the item at the specified root URL
|
||||
|
||||
Vendored
+1
-1
@@ -812,7 +812,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)updateAccessTimeOfItemsRecursivelyAtURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)updateAccessTimeOfItemAtRootURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![self _itemExistsAtURL:targetURL]) {
|
||||
if (error != NULL) {
|
||||
|
||||
Vendored
+1
-1
@@ -90,7 +90,7 @@
|
||||
// The system periodically cleans up files by looking at the mod & access times, so we have to make sure they're up to date
|
||||
// They could be potentially be preserved when archiving an application, but also an update could just be sitting on the system for a long time
|
||||
// before being installed
|
||||
if (![fileManager updateAccessTimeOfItemsRecursivelyAtURL:newURL error:error]) {
|
||||
if (![fileManager updateAccessTimeOfItemAtRootURL:newURL error:error]) {
|
||||
SULog(@"Failed to recursively update new application's modification time before moving into temporary directory");
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class SUFileManagerTest: XCTestCase
|
||||
}
|
||||
|
||||
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
|
||||
XCTAssertNil(try? fileManager.updateAccessTimeOfItemsRecursivelyAtURL(rootURL.URLByAppendingPathComponent("does not exist")))
|
||||
XCTAssertNil(try? fileManager.updateAccessTimeOfItemAtRootURL(rootURL.URLByAppendingPathComponent("does not exist")))
|
||||
|
||||
let oldOrdinaryFileTime = accessTime(ordinaryFileURL)!
|
||||
let oldDirectoryTime = accessTime(directoryURL)!
|
||||
@@ -292,16 +292,16 @@ class SUFileManagerTest: XCTestCase
|
||||
XCTAssertTrue(timespecEqual(oldValidSymlinkTime, accessTime(validSymlinkURL)!))
|
||||
|
||||
// Test the symlink and make sure the target directory doesn't change
|
||||
try! fileManager.updateAccessTimeOfItemsRecursivelyAtURL(validSymlinkURL)
|
||||
try! fileManager.updateAccessTimeOfItemAtRootURL(validSymlinkURL)
|
||||
XCTAssertFalse(timespecEqual(oldValidSymlinkTime, accessTime(validSymlinkURL)!))
|
||||
XCTAssertTrue(timespecEqual(oldDirectoryTime, accessTime(directoryURL)!))
|
||||
|
||||
// Test an ordinary file
|
||||
try! fileManager.updateAccessTimeOfItemsRecursivelyAtURL(ordinaryFileURL)
|
||||
try! fileManager.updateAccessTimeOfItemAtRootURL(ordinaryFileURL)
|
||||
XCTAssertFalse(timespecEqual(oldOrdinaryFileTime, accessTime(ordinaryFileURL)!))
|
||||
|
||||
// Test the directory and file inside the directory
|
||||
try! fileManager.updateAccessTimeOfItemsRecursivelyAtURL(directoryURL)
|
||||
try! fileManager.updateAccessTimeOfItemAtRootURL(directoryURL)
|
||||
let newDirectoryTime = accessTime(directoryURL)!
|
||||
XCTAssertFalse(timespecEqual(oldDirectoryTime, newDirectoryTime))
|
||||
XCTAssertTrue(timespecEqual(newDirectoryTime, accessTime(fileInDirectoryURL)!))
|
||||
|
||||
Reference in new issue
Block a user