Limit file attribute warning on windows

This commit is contained in:
Fred Park 2018-04-17 07:26:07 -07:00
Родитель 2a6dbbf4ce
Коммит ab5bffbb6b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3C4D545F457737EB
2 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -86,6 +86,7 @@ VectoredNextEntry = collections.namedtuple(
'name',
]
)
_FILEATTR_WARNED_ON_WINDOWS = False
def get_md5_from_metadata(ase):
@ -119,8 +120,12 @@ def generate_fileattr_metadata(local_path, metadata):
:return: merged metadata dictionary
"""
if blobxfer.util.on_windows():
logger.warning(
'file attributes store/restore on Windows is not supported yet')
global _FILEATTR_WARNED_ON_WINDOWS
if not _FILEATTR_WARNED_ON_WINDOWS:
_FILEATTR_WARNED_ON_WINDOWS = True
logger.warning(
'file attributes store/restore on Windows is not '
'supported yet')
return None
else:
md = {
@ -149,9 +154,12 @@ def fileattr_from_metadata(md):
return None
else:
if blobxfer.util.on_windows():
logger.warning(
'file attributes store/restore on Windows is not supported '
'yet')
global _FILEATTR_WARNED_ON_WINDOWS
if not _FILEATTR_WARNED_ON_WINDOWS:
_FILEATTR_WARNED_ON_WINDOWS = True
logger.warning(
'file attributes store/restore on Windows is not '
'supported yet')
fileattr = None
else:
try:

Просмотреть файл

@ -37,7 +37,9 @@ def test_get_md5_from_metadata():
def test_generate_fileattr_metadata():
with mock.patch('blobxfer.util.on_windows', return_value=True):
md._FILEATTR_WARNED_ON_WINDOWS = False
assert md.generate_fileattr_metadata(None, None) is None
assert md._FILEATTR_WARNED_ON_WINDOWS
with mock.patch('blobxfer.util.on_windows', return_value=False):
lp = mock.MagicMock()
@ -65,11 +67,13 @@ def test_fileattr_from_metadata():
assert md.fileattr_from_metadata(None) is None
with mock.patch('blobxfer.util.on_windows', return_value=True):
md._FILEATTR_WARNED_ON_WINDOWS = False
val = {
md.JSON_KEY_BLOBXFER_METADATA: json.dumps(
{md._JSON_KEY_FILE_ATTRIBUTES: {}})
}
assert md.fileattr_from_metadata(val) is None
assert md._FILEATTR_WARNED_ON_WINDOWS
with mock.patch('blobxfer.util.on_windows', return_value=False):
lp = mock.MagicMock()