The Update That Redirected Your Documents Away — JavaScript Bug Hunt

Modelled on the Windows 10 October 2018 Update (build 1809): known-folder redirection had left some users with two Documents folders.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Migration, Data Loss
  • Modelled on: Windows 10 · 1809
  • Visible tests: an empty old folder is removed; a folder with files is never removed
  • Reward: 50 XP for a complete fix

Briefing

Modelled on the Windows 10 October 2018 Update (build 1809): known-folder redirection had left some users with two Documents folders. The updater deleted the original folder without checking whether it still held files, and people lost photos and documents. Microsoft pulled the update within days.

redirect.js performs the same cleanup and skips the emptiness check.

Fix cleanupOldFolder so a folder with contents is never removed.

Bug report

BUG-1809 · Priority: Critical (data loss) · Reported by: update reliability

cleanupOldFolder(fs, oldPath, newPath) must:

  • remove oldPath only when it exists AND is empty
  • never remove it when it still contains files
  • never remove newPath under any circumstance
  • return { removed: bool, reason: "ok" | "not-empty" | "missing" | "same" }

Observed: the old folder is deleted unconditionally, taking its contents with it.

Logs

[kfr] removed C:\Users\sam\Documents (14,203 files)
[kfr] redirect target C:\OneDrive\Documents contained 0 of them

The code as shipped

src/update/redirect.js (editable)

// Removes the pre-redirect folder after a known-folder move.
exports.cleanupOldFolder = function (fs, oldPath, newPath) {
  delete fs[oldPath];
  return { removed: true, reason: "ok" };
};

Read-only context: src/update/FS.js.

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.