Changeset 287639 in webkit
- Timestamp:
- Jan 5, 2022, 11:19:31 AM (5 years ago)
- Location:
- branches/safari-613.1.12.1-branch
- 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
-
branches/safari-613.1.12.1-branch/Source/WTF/ChangeLog
r287165 r287639 1 2022-01-05 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r287377. rdar://problem/86829012 4 5 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 6 https://bugs.webkit.org/show_bug.cgi?id=234404 7 8 Reviewed by Youenn Fablet. 9 10 Source/WebKit: 11 12 createDirectoryAtURL returning false means directory cannot be created, but the cause can be that directory 13 already exists; so we should set exclude attribute on the directory no matter createDirectoryAtURL returns true 14 or false. Also, we can use existing FileSystem functions. 15 16 API test: WKWebView.LocalStorageDirectoryExcludedFromBackup 17 18 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 19 (WebKit::WebsiteDataStore::excludeDirectoryFromBackup): Deleted. 20 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 21 (WebKit::WebsiteDataStore::parameters): 22 * UIProcess/WebsiteData/WebsiteDataStore.h: 23 24 Source/WTF: 25 26 * wtf/FileSystem.cpp: 27 (WTF::FileSystemImpl::excludeFromBackup): 28 (WTF::FileSystemImpl::canExcludeFromBackup): Deleted. 29 * wtf/FileSystem.h: 30 * wtf/cocoa/FileSystemCocoa.mm: 31 (WTF::FileSystemImpl::excludeFromBackup): 32 * wtf/mac/FileSystemMac.mm: 33 (WTF::FileSystem::canExcludeFromBackup): Deleted. 34 (WTF::FileSystem::excludeFromBackup): Deleted. 35 36 Tools: 37 38 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 39 (TEST): 40 41 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287377 268f45cc-cd09-0410-ab3c-d52691b4dbfc 42 43 2021-12-22 Sihui Liu <sihui_liu@apple.com> 44 45 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 46 https://bugs.webkit.org/show_bug.cgi?id=234404 47 48 Reviewed by Youenn Fablet. 49 50 * wtf/FileSystem.cpp: 51 (WTF::FileSystemImpl::excludeFromBackup): 52 (WTF::FileSystemImpl::canExcludeFromBackup): Deleted. 53 * wtf/FileSystem.h: 54 * wtf/cocoa/FileSystemCocoa.mm: 55 (WTF::FileSystemImpl::excludeFromBackup): 56 * wtf/mac/FileSystemMac.mm: 57 (WTF::FileSystem::canExcludeFromBackup): Deleted. 58 (WTF::FileSystem::excludeFromBackup): Deleted. 59 1 60 2021-12-16 Alan Coon <alancoon@apple.com> 2 61 -
branches/safari-613.1.12.1-branch/Source/WTF/wtf/FileSystem.cpp
r286883 r287639 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 -
branches/safari-613.1.12.1-branch/Source/WTF/wtf/FileSystem.h
r286883 r287639 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. -
branches/safari-613.1.12.1-branch/Source/WTF/wtf/cocoa/FileSystemCocoa.mm
r278431 r287639 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 -
branches/safari-613.1.12.1-branch/Source/WTF/wtf/mac/FileSystemMac.mm
r285588 r287639 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 -
branches/safari-613.1.12.1-branch/Source/WebKit/ChangeLog
r287594 r287639 1 2022-01-05 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r287377. rdar://problem/86829012 4 5 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 6 https://bugs.webkit.org/show_bug.cgi?id=234404 7 8 Reviewed by Youenn Fablet. 9 10 Source/WebKit: 11 12 createDirectoryAtURL returning false means directory cannot be created, but the cause can be that directory 13 already exists; so we should set exclude attribute on the directory no matter createDirectoryAtURL returns true 14 or false. Also, we can use existing FileSystem functions. 15 16 API test: WKWebView.LocalStorageDirectoryExcludedFromBackup 17 18 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 19 (WebKit::WebsiteDataStore::excludeDirectoryFromBackup): Deleted. 20 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 21 (WebKit::WebsiteDataStore::parameters): 22 * UIProcess/WebsiteData/WebsiteDataStore.h: 23 24 Source/WTF: 25 26 * wtf/FileSystem.cpp: 27 (WTF::FileSystemImpl::excludeFromBackup): 28 (WTF::FileSystemImpl::canExcludeFromBackup): Deleted. 29 * wtf/FileSystem.h: 30 * wtf/cocoa/FileSystemCocoa.mm: 31 (WTF::FileSystemImpl::excludeFromBackup): 32 * wtf/mac/FileSystemMac.mm: 33 (WTF::FileSystem::canExcludeFromBackup): Deleted. 34 (WTF::FileSystem::excludeFromBackup): Deleted. 35 36 Tools: 37 38 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 39 (TEST): 40 41 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287377 268f45cc-cd09-0410-ab3c-d52691b4dbfc 42 43 2021-12-22 Sihui Liu <sihui_liu@apple.com> 44 45 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 46 https://bugs.webkit.org/show_bug.cgi?id=234404 47 48 Reviewed by Youenn Fablet. 49 50 createDirectoryAtURL returning false means directory cannot be created, but the cause can be that directory 51 already exists; so we should set exclude attribute on the directory no matter createDirectoryAtURL returns true 52 or false. Also, we can use existing FileSystem functions. 53 54 API test: WKWebView.LocalStorageDirectoryExcludedFromBackup 55 56 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 57 (WebKit::WebsiteDataStore::excludeDirectoryFromBackup): Deleted. 58 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 59 (WebKit::WebsiteDataStore::parameters): 60 * UIProcess/WebsiteData/WebsiteDataStore.h: 61 1 62 2022-01-04 Alan Coon <alancoon@apple.com> 2 63 -
branches/safari-613.1.12.1-branch/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r286936 r287639 645 645 } 646 646 647 #if PLATFORM(IOS_FAMILY) 648 649 void WebsiteDataStore::excludeDirectoryFromBackup(const String& directory) 650 { 651 NSURL *url = [NSURL URLWithString:(NSString *)directory]; 652 if ([[NSFileManager defaultManager] createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:nullptr]) 653 [[NSURL fileURLWithPath:(NSString *)directory isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil]; 654 } 655 656 #endif 657 658 } 647 } -
branches/safari-613.1.12.1-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r286936 r287639 1904 1904 if (!localStorageDirectory.isEmpty()) { 1905 1905 parameters.localStorageDirectory = localStorageDirectory; 1906 #if PLATFORM(IOS_FAMILY)1907 excludeDirectoryFromBackup(localStorageDirectory);1908 #endif1909 1906 // FIXME: SandboxExtension::createHandleForReadWriteDirectory resolves the directory, but that has already been done. Remove this duplicate work. 1910 1907 if (auto handle = SandboxExtension::createHandleForReadWriteDirectory(localStorageDirectory)) 1911 1908 parameters.localStorageDirectoryExtensionHandle = WTFMove(*handle); 1909 #if PLATFORM(IOS_FAMILY) 1910 FileSystem::makeAllDirectories(localStorageDirectory); 1911 FileSystem::excludeFromBackup(localStorageDirectory); 1912 #endif 1912 1913 } 1913 1914 -
branches/safari-613.1.12.1-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r286936 r287639 372 372 void countNonDefaultSessionSets(CompletionHandler<void(size_t)>&&); 373 373 374 #if PLATFORM(IOS_FAMILY)375 void excludeDirectoryFromBackup(const String& directory);376 #endif377 378 374 private: 379 375 enum class ForceReinitialization : bool { No, Yes }; -
branches/safari-613.1.12.1-branch/Tools/ChangeLog
r287061 r287639 1 2022-01-05 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r287377. rdar://problem/86829012 4 5 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 6 https://bugs.webkit.org/show_bug.cgi?id=234404 7 8 Reviewed by Youenn Fablet. 9 10 Source/WebKit: 11 12 createDirectoryAtURL returning false means directory cannot be created, but the cause can be that directory 13 already exists; so we should set exclude attribute on the directory no matter createDirectoryAtURL returns true 14 or false. Also, we can use existing FileSystem functions. 15 16 API test: WKWebView.LocalStorageDirectoryExcludedFromBackup 17 18 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 19 (WebKit::WebsiteDataStore::excludeDirectoryFromBackup): Deleted. 20 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 21 (WebKit::WebsiteDataStore::parameters): 22 * UIProcess/WebsiteData/WebsiteDataStore.h: 23 24 Source/WTF: 25 26 * wtf/FileSystem.cpp: 27 (WTF::FileSystemImpl::excludeFromBackup): 28 (WTF::FileSystemImpl::canExcludeFromBackup): Deleted. 29 * wtf/FileSystem.h: 30 * wtf/cocoa/FileSystemCocoa.mm: 31 (WTF::FileSystemImpl::excludeFromBackup): 32 * wtf/mac/FileSystemMac.mm: 33 (WTF::FileSystem::canExcludeFromBackup): Deleted. 34 (WTF::FileSystem::excludeFromBackup): Deleted. 35 36 Tools: 37 38 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 39 (TEST): 40 41 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287377 268f45cc-cd09-0410-ab3c-d52691b4dbfc 42 43 2021-12-22 Sihui Liu <sihui_liu@apple.com> 44 45 WebsiteDataStore::excludeDirectoryFromBackup should set attribute for existing directories 46 https://bugs.webkit.org/show_bug.cgi?id=234404 47 48 Reviewed by Youenn Fablet. 49 50 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 51 (TEST): 52 1 53 2021-12-13 Youenn Fablet <youenn@apple.com> 2 54 -
branches/safari-613.1.12.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm
r285547 r287639 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.