Merge "Fix quarantine when object path is not a directory"
This commit is contained in:
commit
b4c8cf192a
@ -1132,7 +1132,14 @@ class BaseDiskFileManager(object):
|
||||
partition_path = dirname(path)
|
||||
objects_path = dirname(partition_path)
|
||||
device_path = dirname(objects_path)
|
||||
quar_path = quarantine_renamer(device_path, hsh_path)
|
||||
# The made-up filename is so that the eventual dirpath()
|
||||
# will result in this object directory that we care about.
|
||||
# Some failures will result in an object directory
|
||||
# becoming a file, thus causing the parent directory to
|
||||
# be qarantined.
|
||||
quar_path = quarantine_renamer(device_path,
|
||||
join(hsh_path,
|
||||
"made-up-filename"))
|
||||
logging.exception(
|
||||
_('Quarantined %(hsh_path)s to %(quar_path)s because '
|
||||
'it is not a directory'), {'hsh_path': hsh_path,
|
||||
@ -1447,7 +1454,14 @@ class BaseDiskFileManager(object):
|
||||
filenames = self.cleanup_ondisk_files(object_path)['files']
|
||||
except OSError as err:
|
||||
if err.errno == errno.ENOTDIR:
|
||||
quar_path = self.quarantine_renamer(dev_path, object_path)
|
||||
# The made-up filename is so that the eventual dirpath()
|
||||
# will result in this object directory that we care about.
|
||||
# Some failures will result in an object directory
|
||||
# becoming a file, thus causing the parent directory to
|
||||
# be qarantined.
|
||||
quar_path = self.quarantine_renamer(dev_path,
|
||||
join(object_path,
|
||||
"made-up-filename"))
|
||||
logging.exception(
|
||||
_('Quarantined %(object_path)s to %(quar_path)s because '
|
||||
'it is not a directory'), {'object_path': object_path,
|
||||
|
@ -1217,7 +1217,8 @@ class DiskFileManagerMixin(BaseDiskFileTestMixin):
|
||||
'dev', '9', '9a7175077c01a23ade5956b8a2bba900', POLICIES[0])
|
||||
quarantine_renamer.assert_called_once_with(
|
||||
'/srv/dev/',
|
||||
'/srv/dev/objects/9/900/9a7175077c01a23ade5956b8a2bba900')
|
||||
('/srv/dev/objects/9/900/9a7175077c01a23ade5956b8a2bba900/' +
|
||||
'made-up-filename'))
|
||||
|
||||
def test_get_diskfile_from_hash_no_dir(self):
|
||||
self.df_mgr.get_dev_path = mock.MagicMock(return_value='/srv/dev/')
|
||||
@ -7707,7 +7708,6 @@ class TestSuffixHashes(unittest.TestCase):
|
||||
quarantine_path = os.path.join(
|
||||
quarantine_base, # quarantine root
|
||||
diskfile.get_data_dir(policy), # per-policy data dir
|
||||
suffix, # first dir from which quarantined file was removed
|
||||
os.path.basename(df._datadir) # name of quarantined file
|
||||
)
|
||||
self.assertTrue(os.path.exists(quarantine_path))
|
||||
|
Loading…
Reference in New Issue
Block a user