Changeset 291014 in webkit
- Timestamp:
- Mar 8, 2022 3:04:42 PM (4 months ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
NetworkProcess/storage/FileSystemStorageHandle.cpp (modified) (2 diffs)
-
NetworkProcess/storage/FileSystemStorageHandle.h (modified) (2 diffs)
-
NetworkProcess/storage/FileSystemStorageManager.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r291010 r291014 1 2022-03-08 Sihui Liu <sihui_liu@apple.com> 2 3 File System Access: throw exception if file or directory cannot be accessed in file system 4 https://bugs.webkit.org/show_bug.cgi?id=237537 5 6 Reviewed by Youenn Fablet. 7 8 When a FileSystemHandle is created, we will ensure that corresponding directory or file exists (create the 9 directory or file if it does not exist yet). However, we did not check the result of the file system calls. 10 That means, we may fail to create the file (e.g. due to no disk space, or cases in rdar://89291566), but we 11 still return success to the FileSystemHandle creation request. We should fix this by checking the file system 12 call's result before completing the request. 13 14 * NetworkProcess/storage/FileSystemStorageHandle.cpp: 15 (WebKit::FileSystemStorageHandle::create): 16 (WebKit::FileSystemStorageHandle::FileSystemStorageHandle): 17 * NetworkProcess/storage/FileSystemStorageHandle.h: 18 * NetworkProcess/storage/FileSystemStorageManager.cpp: 19 (WebKit::FileSystemStorageManager::createHandle): 20 1 21 2022-03-08 Commit Queue <commit-queue@webkit.org> 2 22 -
trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp
r290998 r291014 40 40 #endif 41 41 42 std::unique_ptr<FileSystemStorageHandle> FileSystemStorageHandle::create(FileSystemStorageManager& manager, Type type, String&& path, String&& name) 43 { 44 bool canAccess = false; 45 switch (type) { 46 case FileSystemStorageHandle::Type::Directory: 47 canAccess = FileSystem::makeAllDirectories(path); 48 break; 49 case FileSystemStorageHandle::Type::File: 50 if (auto handle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write); FileSystem::isHandleValid(handle)) { 51 FileSystem::closeFile(handle); 52 canAccess = true; 53 } 54 break; 55 case FileSystemStorageHandle::Type::Any: 56 ASSERT_NOT_REACHED(); 57 } 58 59 if (!canAccess) 60 return nullptr; 61 62 return std::unique_ptr<FileSystemStorageHandle>(new FileSystemStorageHandle(manager, type, WTFMove(path), WTFMove(name))); 63 } 64 42 65 FileSystemStorageHandle::FileSystemStorageHandle(FileSystemStorageManager& manager, Type type, String&& path, String&& name) 43 66 : m_identifier(WebCore::FileSystemHandleIdentifier::generateThreadSafe()) … … 48 71 { 49 72 ASSERT(!m_path.isEmpty()); 50 51 switch (m_type) {52 case FileSystemStorageHandle::Type::Directory:53 FileSystem::makeAllDirectories(m_path);54 return;55 case FileSystemStorageHandle::Type::File:56 if (!FileSystem::fileExists(m_path)) {57 auto handle = FileSystem::openFile(m_path, FileSystem::FileOpenMode::Write);58 FileSystem::closeFile(handle);59 }60 return;61 case FileSystemStorageHandle::Type::Any:62 ASSERT_NOT_REACHED();63 }64 73 } 65 74 -
trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.h
r287156 r291014 44 44 public: 45 45 enum class Type : uint8_t { File, Directory, Any }; 46 FileSystemStorageHandle(FileSystemStorageManager&, Type, String&& path, String&& name);46 static std::unique_ptr<FileSystemStorageHandle> create(FileSystemStorageManager&, Type, String&& path, String&& name); 47 47 48 48 WebCore::FileSystemHandleIdentifier identifier() const { return m_identifier; } … … 66 66 67 67 private: 68 FileSystemStorageHandle(FileSystemStorageManager&, Type, String&& path, String&& name); 68 69 Expected<WebCore::FileSystemHandleIdentifier, FileSystemStorageError> requestCreateHandle(IPC::Connection::UniqueID, Type, String&& name, bool createIfNecessary); 69 70 -
trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp
r289012 r291014 78 78 } 79 79 80 auto newHandle = makeUnique<FileSystemStorageHandle>(*this, type, WTFMove(path), WTFMove(name)); 80 auto newHandle = FileSystemStorageHandle::create(*this, type, WTFMove(path), WTFMove(name)); 81 if (!newHandle) 82 return makeUnexpected(FileSystemStorageError::Unknown); 81 83 auto newHandleIdentifier = newHandle->identifier(); 82 84 m_handlesByConnection.ensure(connection, [&] {
Note: See TracChangeset
for help on using the changeset viewer.