Skip to content
Open
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
12 changes: 8 additions & 4 deletions backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,22 @@ def extract_tunnel(nodes):
batadv_graph = graph.merge_nodes(batadv_graph)
batadv_graph = graph.to_undirected(batadv_graph)

# write processed data to dest dir
with open(nodes_fn, 'w') as f:
# write processed data to temporary files in dest dir
# and rename them atomically to prevent inconsistent data
with open(nodes_fn + '.tmp', 'w') as f:
json.dump(nodedb, f)
os.rename(nodes_fn + '.tmp', nodes_fn)

graph_out = {'batadv': json_graph.node_link_data(batadv_graph),
'version': GRAPH_VERSION}

with open(graph_fn, 'w') as f:
with open(graph_fn + '.tmp', 'w') as f:
json.dump(graph_out, f)
os.rename(graph_fn + '.tmp', graph_fn)

with open(nodelist_fn, 'w') as f:
with open(nodelist_fn + 'tmp', 'w') as f:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a '.' missing in front of the tmp'

json.dump(export_nodelist(now, nodedb), f)
os.rename(nodelist_fn + '.tmp', nodelist_fn)

# optional rrd graphs (trigger with --rrd)
if params['rrd']:
Expand Down