Verified Commit be59c235 authored by Jari Jalkanen's avatar Jari Jalkanen Committed by ma1
Browse files

Bug 2058651: Stop WritableFileStreams from following moved paths. a=diannaS DONTBUILD

parent 8bb484e1
Loading
Loading
Loading
Loading
+2 −0
Changes for dom/fs/parent/FileSystemHashSource.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ Result<EntryId, QMResult> FileSystemHashSource::GenerateHash(

Result<Name, QMResult> FileSystemHashSource::EncodeHash(const FileId& aFileId) {
  MOZ_ASSERT(32u == aFileId.Value().Length());
  QM_TRY(OkIf(32u == aFileId.Value().Length()),
         Err(QMResult(NS_ERROR_DOM_NOT_FOUND_ERR)));
  nsCString encoded;
  base32encode(&aFileId.Value(), &encoded);

+11 −6
Changes for dom/fs/parent/datamodel/FileSystemDatabaseManagerVersion002.cpp: 11 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ Result<FileId, QMResult> GetFileId002(const FileSystemConnection& aConnection,
  QM_TRY(QM_TO_RESULT(stmt.BindEntryIdByName("entryId"_ns, aEntryId)));
  QM_TRY_UNWRAP(bool moreResults, stmt.ExecuteStep());

  if (!moreResults) {
  if (!moreResults || stmt.IsNullByColumn(/* Column */ 0u)) {
    return Err(QMResult(NS_ERROR_DOM_NOT_FOUND_ERR));
  }

@@ -95,7 +95,11 @@ nsresult RehashFile(const FileSystemConnection& aConnection,
                                       : insertNewFileAndTypeQuery;

  const nsLiteralCString updateFileMappingsQuery =
      "UPDATE FileIds SET handle = :newId WHERE handle = :handle ;"_ns;
      "UPDATE FileIds SET handle = :newId "
      "FROM MainFiles WHERE MainFiles.handle = :handle "
      "AND FileIds.fileId = MainFiles.fileId "
      "AND FileIds.handle = :handle "
      ";"_ns;

  const nsLiteralCString updateMainFilesQuery =
      "UPDATE MainFiles SET handle = :newId WHERE handle = :handle ;"_ns;
@@ -204,14 +208,14 @@ nsresult RehashDirectory(const FileSystemConnection& aConnection,

  const nsLiteralCString updateFileMappingsQuery =
      "UPDATE FileIds "
      "SET handle = CASE WHEN replacement.isMain IS NULL THEN NULL "
      "ELSE replacement.hash END "
      "SET handle = replacement.hash "
      "FROM ( SELECT ParentChildHash.handle AS handle, "
      "ParentChildHash.hash AS hash, "
      "MainFiles.handle AS isMain "
      "FROM ParentChildHash LEFT JOIN MainFiles "
      "MainFiles.fileId AS mainFileId "
      "FROM ParentChildHash INNER JOIN MainFiles "
      "ON ParentChildHash.handle = MainFiles.handle ) AS replacement "
      "WHERE FileIds.handle = replacement.handle "
      "AND FileIds.fileId = replacement.mainFileId "
      ";"_ns;

  const nsLiteralCString updateMainFilesQuery =
@@ -666,6 +670,7 @@ Result<FileId, QMResult> FileSystemDatabaseManagerVersion002::EnsureFileId(
                    })));

  if (maybeMainFileId) {
    MOZ_ASSERT(!maybeMainFileId->IsEmpty());
    return *maybeMainFileId;
  }