classification
Title: Add copy_directory_metadata parameter to shutil.copytree
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: desbma, giampaolo.rodola
Priority: normal Keywords: patch

Created on 2017-11-18 19:13 by desbma, last changed 2018-06-12 09:41 by giampaolo.rodola.

Pull Requests
URL Status Linked Edit
PR 4456 open desbma, 2017-11-18 19:27
Messages (2)
msg306494 - (view) Author: desbma (desbma) * Date: 2017-11-18 19:13
I am sometimes using shutil.copytree to copy a directory to a destination that does not support setting metadata (like MTP mounts of Android devices).

Using the copy_function parameter allows passing shutil.copy or a custom function to ignore file metadata, however currently shutil.copytree always tries to call copystat on directories, which can fail with OSError (errno set to ENOTSUPP).

The code assumes copystat can fail on Windows, but propagates the error on other OS, even though the tree copy actually succeeds.
See https://github.com/python/cpython/blob/9bb6fe52742340f6c92f0dda18599a4577a94e18/Lib/shutil.py#L352-L357
msg308628 - (view) Author: desbma (desbma) * Date: 2017-12-19 11:49
Ping
History
Date User Action Args
2018-06-12 09:41:30giampaolo.rodolasetnosy: + giampaolo.rodola
2017-12-19 11:49:25desbmasetmessages: + msg308628
2017-11-18 19:27:13desbmasetkeywords: + patch
stage: patch review
pull_requests: + pull_request4394
2017-11-18 19:13:27desbmacreate