Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,6 @@ def write_cache(id: str, path: str, tree: MypyFile,
os.makedirs(parent, exist_ok=True)
assert os.path.dirname(meta_json) == parent

# Construct temp file names
nonce = '.' + random_string()
data_json_tmp = data_json + nonce
meta_json_tmp = meta_json + nonce

# Serialize data and analyze interface
data = tree.serialize()
if manager.options.debug_cache:
Expand Down Expand Up @@ -897,11 +892,10 @@ def write_cache(id: str, path: str, tree: MypyFile,
data_mtime = os.path.getmtime(data_json)
manager.trace("Interface for {} is unchanged".format(id))
else:
with open(data_json_tmp, 'w') as f:
with open(data_json, 'w') as f:
f.write(data_str)
f.write('\n')
data_mtime = os.path.getmtime(data_json_tmp)
os.replace(data_json_tmp, data_json)
data_mtime = os.path.getmtime(data_json)
manager.trace("Interface for {} has changed".format(id))

mtime = st.st_mtime
Expand All @@ -922,12 +916,11 @@ def write_cache(id: str, path: str, tree: MypyFile,
}

# Write meta cache file
with open(meta_json_tmp, 'w') as f:
with open(meta_json, 'w') as f:
if manager.options.debug_cache:
json.dump(meta, f, indent=2, sort_keys=True)
else:
json.dump(meta, f)
os.replace(meta_json_tmp, meta_json)

return interface_hash

Expand Down