Skip to content

Commit

Permalink
Fixed a bug where renaming empty folders would delete them from the d…
Browse files Browse the repository at this point in the history
…isk, instead.

Resolve #7221
  • Loading branch information
andris-sevcenko committed Mar 26, 2021
1 parent dcb86ca commit 4ce5c7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed
- Fixed a bug where Matrix field changes on the Current revision weren’t getting propagated to drafts when the “Merge changes into draft” button was clicked. ([#7727](https://github.com/craftcms/cms/issues/7727))
- Fixed an error that occurred when publishing a draft with an outdated Matrix field. ([#7727](https://github.com/craftcms/cms/issues/7727))
- Fixed a bug where renaming empty folders would delete them from the disk, instead. ([#7221](https://github.com/craftcms/cms/issues/7721))

## 3.6.11.1 - 2021-03-24

Expand Down
6 changes: 6 additions & 0 deletions src/base/FlysystemVolume.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ public function renameDirectory(string $path, string $newName)
}
}

// Work around an edge case were empty folders would cause the containing folder to be deleted instead of renamed
if (empty($fileList)) {
$this->renameFile($path, $newPath . '/' . $newName);
return;
}

// It's possible for a folder object to not exist on remote volumes, so to throw an exception
// we must make sure that there are no files AS WELL as no folder.
if (empty($fileList) && !$this->folderExists($path)) {
Expand Down

0 comments on commit 4ce5c7c

Please sign in to comment.