Description
In certain cases, renameing a page fail with OS Error "Directory not empty".
Example
Try to rename the page AlexanderSchremmer/TestPage1 to AlexanderSchremmer/TestPage2
You can reanme this pag3e to TextPage1, 3... but not 2.
Details
this wiki
Workaround
Don't use this name
Discussion
Rename is just a directory rename. If the directory exists before the rename, you should get an error message "This page already exists". Maybe page.exists() is broken and does not report certain page directories.
current page.exists do ignore deleted pages. There could be other sorts of "junk" page direcories, due to errors in other places. We need Page.rename(old, new) function that:
- check if name is available - not with page.exists()
- If there is a page with that name, get that page state - if it is a junk page, like empty directory or no content, delete it.
- aquire a lock, so new name is saved form multiple rename/creation
- rename using os.rename
- release lock
most of this code is today at the rename action, but it should be at the storage layer.
For what is the locking around os.rename? It is a single operation and atomic.
- Atomic for files, fail on existing non-empty directories, therefore not atomic. Also not atomic on Win32.
Plan
- Priority: High, crash, function broken
Assigned to: NirSoffer
- Status: fixed (doesn't backtrace at least, but gives error msg)