Commit 36d26314 authored by Merlijn Wajer's avatar Merlijn Wajer
Browse files

metadata: write _meta.xml to separate temporary filesystem

Per Hank:

for our immediate problem, i don’t have a specific theory of causation.
there are multiple possible causes, and we don’t have enough information
to distinguish among them. i would like to try the suggested procedure
(writing to a tmp dir, testing there, then moving the file into the item
dir, even if that entails a copy across filesystems) because

(1) it has diagnostic value, helping us narrow down possible causes based on
    whether the problem recurs,
(2) if at all possible, i want to preserve the practice of moving or
    copying only complete, known-good, files into the item dir, breaking
    that convention as a last resort once we’ve determined it’s the only way
    to resolve this problem.
parent e1abb906
from os import rename, stat, remove, fsync, posix_fadvise, \
POSIX_FADV_DONTNEED, chmod, close, stat
from shutil import move
from os.path import join
from tempfile import mkstemp
......@@ -109,7 +110,7 @@ def write_item_metadata(identifier, metadata):
* Nothing
"""
metaxml = metadata_to_metaxml(metadata)
fp, tmp_path = mkstemp(suffix='.xml', dir=PB_ITEM, text=True)
fp, tmp_path = mkstemp(suffix='.xml', dir=PB_TMP, text=True)
close(fp)
# We write the XML to a temporary file, flush it, sync it to disk, and
......@@ -133,7 +134,7 @@ def write_item_metadata(identifier, metadata):
meta_xml_path = join(PB_ITEM, '%s_meta.xml' % identifier)
st = stat(meta_xml_path)
chmod(tmp_path, st.st_mode)
rename(tmp_path, meta_xml_path)
move(tmp_path, meta_xml_path)
def load_files_metadata(identifier):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment