Changeset 287377 in webkit
- Timestamp:
- Dec 22, 2021, 3:55:10 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/FileSystem.cpp (modified) (2 diffs)
-
Source/WTF/wtf/FileSystem.h (modified) (1 diff)
-
Source/WTF/wtf/cocoa/FileSystemCocoa.mm (modified) (1 diff)
-
Source/WTF/wtf/mac/FileSystemMac.mm (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r287372 r287377 1 2021-12-22 Sihui Liu <sihui_liu@apple.com> 2 3 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 4 https://bugs.webkit.org/show_bug.cgi?id=234404 5 6 Reviewed by Youenn Fablet. 7 8 * wtf/FileSystem.cpp: 9 (WTF::FileSystemImpl::excludeFromBackup): 10 (WTF::FileSystemImpl::canExcludeFromBackup): Deleted. 11 * wtf/FileSystem.h: 12 * wtf/cocoa/FileSystemCocoa.mm: 13 (WTF::FileSystemImpl::excludeFromBackup): 14 * wtf/mac/FileSystemMac.mm: 15 (WTF::FileSystem::canExcludeFromBackup): Deleted. 16 (WTF::FileSystem::excludeFromBackup): Deleted. 17 1 18 2021-12-22 Commit Queue <commit-queue@webkit.org> 2 19 -
trunk/Source/WTF/wtf/FileSystem.cpp
r287080 r287377 306 306 } 307 307 308 bool canExcludeFromBackup()309 {310 return false;311 }312 313 bool excludeFromBackup(const String&)314 {315 return false;316 }317 318 308 #endif 319 309 … … 427 417 428 418 #if !PLATFORM(COCOA) 419 429 420 String createTemporaryZipArchive(const String&) 430 421 { 431 422 return { }; 432 423 } 424 425 bool excludeFromBackup(const String&) 426 { 427 return false; 428 } 429 433 430 #endif 434 431 -
trunk/Source/WTF/wtf/FileSystem.h
r286883 r287377 135 135 136 136 WTF_EXPORT_PRIVATE void setMetadataURL(const String& path, const String& urlString, const String& referrer = { }); 137 138 bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup. 139 bool excludeFromBackup(const String&); // Returns true if successful. 137 WTF_EXPORT_PRIVATE bool excludeFromBackup(const String&); // Returns true if successful. 140 138 141 139 WTF_EXPORT_PRIVATE Vector<String> listDirectory(const String& path); // Returns file names, not full paths. -
trunk/Source/WTF/wtf/cocoa/FileSystemCocoa.mm
r278431 r287377 223 223 #endif 224 224 225 bool excludeFromBackup(const String& path) 226 { 227 NSError *error; 228 if (![[NSURL fileURLWithPath:(NSString *)path isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:&error]) { 229 LOG_ERROR("Cannot exclude path '%s' from backup with error '%@'", path.utf8().data(), error.localizedDescription); 230 return false; 231 } 232 233 return true; 234 } 235 225 236 } // namespace FileSystemImpl 226 237 } // namespace WTF -
trunk/Source/WTF/wtf/mac/FileSystemMac.mm
r285588 r287377 58 58 } 59 59 60 bool FileSystem::canExcludeFromBackup()61 {62 return true;63 }64 65 bool FileSystem::excludeFromBackup(const String& path)66 {67 // It is critical to pass FALSE for excludeByPath because excluding by path requires root privileges.68 CSBackupSetItemExcluded(FileSystem::pathAsURL(path).get(), TRUE, FALSE);69 return true;70 }71 72 60 } // namespace WTF 73 61 -
trunk/Source/WebKit/ChangeLog
r287374 r287377 1 2021-12-22 Sihui Liu <sihui_liu@apple.com> 2 3 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 4 https://bugs.webkit.org/show_bug.cgi?id=234404 5 6 Reviewed by Youenn Fablet. 7 8 createDirectoryAtURL returning false means directory cannot be created, but the cause can be that directory 9 already exists; so we should set exclude attribute on the directory no matter createDirectoryAtURL returns true 10 or false. Also, we can use existing FileSystem functions. 11 12 API test: WKWebView.LocalStorageDirectoryExcludedFromBackup 13 14 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 15 (WebKit::WebsiteDataStore::excludeDirectoryFromBackup): Deleted. 16 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 17 (WebKit::WebsiteDataStore::parameters): 18 * UIProcess/WebsiteData/WebsiteDataStore.h: 19 1 20 2021-12-22 Alex Christensen <achristensen@webkit.org> 2 21 -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r287344 r287377 641 641 } 642 642 643 #if PLATFORM(IOS_FAMILY) 644 645 void WebsiteDataStore::excludeDirectoryFromBackup(const String& directory) 646 { 647 NSURL *url = [NSURL fileURLWithPath:(NSString *)directory isDirectory:YES]; 648 if ([[NSFileManager defaultManager] createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:nullptr]) 649 [url setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil]; 650 } 651 652 #endif 653 654 } 643 } -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r287371 r287377 1915 1915 if (!localStorageDirectory.isEmpty()) { 1916 1916 parameters.localStorageDirectory = localStorageDirectory; 1917 #if PLATFORM(IOS_FAMILY)1918 excludeDirectoryFromBackup(localStorageDirectory);1919 #endif1920 1917 // FIXME: SandboxExtension::createHandleForReadWriteDirectory resolves the directory, but that has already been done. Remove this duplicate work. 1921 1918 if (auto handle = SandboxExtension::createHandleForReadWriteDirectory(localStorageDirectory)) 1922 1919 parameters.localStorageDirectoryExtensionHandle = WTFMove(*handle); 1920 #if PLATFORM(IOS_FAMILY) 1921 FileSystem::makeAllDirectories(localStorageDirectory); 1922 FileSystem::excludeFromBackup(localStorageDirectory); 1923 #endif 1923 1924 } 1924 1925 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r287371 r287377 373 373 void countNonDefaultSessionSets(CompletionHandler<void(size_t)>&&); 374 374 375 #if PLATFORM(IOS_FAMILY)376 void excludeDirectoryFromBackup(const String& directory);377 #endif378 379 375 private: 380 376 enum class ForceReinitialization : bool { No, Yes }; -
trunk/Tools/ChangeLog
r287374 r287377 1 2021-12-22 Sihui Liu <sihui_liu@apple.com> 2 3 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 4 https://bugs.webkit.org/show_bug.cgi?id=234404 5 6 Reviewed by Youenn Fablet. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 9 (TEST): 10 1 11 2021-12-22 Alex Christensen <achristensen@webkit.org> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm
r285547 r287377 40 40 #import <WebKit/_WKProcessPoolConfiguration.h> 41 41 #import <WebKit/_WKUserStyleSheet.h> 42 #import <WebKit/_WKWebsiteDataStoreConfiguration.h> 42 43 #import <wtf/RetainPtr.h> 43 44 #import <wtf/text/WTFString.h> … … 453 454 runTest(false); 454 455 } 456 457 #if PLATFORM(IOS_FAMILY) 458 459 TEST(WKWebView, LocalStorageDirectoryExcludedFromBackup) 460 { 461 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 462 RetainPtr<NSURL> url = [[[configuration websiteDataStore] _configuration] _webStorageDirectory]; 463 // Create a directory and make it not excluded. 464 [[NSFileManager defaultManager] createDirectoryAtURL:url.get() withIntermediateDirectories:YES attributes:nil error:nullptr]; 465 [url.get() setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:nil]; 466 NSNumber *isDirectoryExcluded = nil; 467 EXPECT_TRUE([url.get() getResourceValue:&isDirectoryExcluded forKey:NSURLIsExcludedFromBackupKey error:nil]); 468 EXPECT_FALSE(isDirectoryExcluded.boolValue); 469 470 auto delegate = adoptNS([[LocalStorageNavigationDelegate alloc] init]); 471 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 472 [webView setNavigationDelegate:delegate.get()]; 473 didFinishNavigationBoolean = false; 474 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 475 [webView loadRequest:request]; 476 TestWebKitAPI::Util::run(&didFinishNavigationBoolean); 477 478 bool finishedRunningScript = false; 479 [webView evaluateJavaScript:@"localStorage.getItem('key');" completionHandler: [&] (id result, NSError *) { 480 finishedRunningScript = true; 481 }]; 482 TestWebKitAPI::Util::run(&finishedRunningScript); 483 484 // Create new url that has updated value. 485 url = [[[configuration websiteDataStore] _configuration] _webStorageDirectory]; 486 EXPECT_TRUE([url.get() getResourceValue:&isDirectoryExcluded forKey:NSURLIsExcludedFromBackupKey error:nil]); 487 EXPECT_TRUE(isDirectoryExcluded.boolValue); 488 } 489 490 #endif
Note:
See TracChangeset
for help on using the changeset viewer.