Skip to content

Commit 03c4643

Browse files
committed
Fix DBusException using Moon activity
Moon activity makes multiple datastore API calls within one second, and the file used to store the data is named by the second of the epoch, such that one API call clashes with another. Use a sequence number instead of the second of the epoch.
1 parent 9fa8cff commit 03c4643

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/jarabe/apisocket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import json
1717
import os
1818
import struct
19-
import time
2019
import binascii
2120

2221
import dbus
@@ -115,12 +114,14 @@ def __init__(self, client):
115114
"/org/laptop/sugar/DataStore")
116115
self._data_store = dbus.Interface(bus_object,
117116
"org.laptop.sugar.DataStore")
117+
self._sequence = 0
118118

119119
def _create_file(self):
120120
activity_root = env.get_profile_path(self._activity.get_type())
121121
instance_path = os.path.join(activity_root, "instance")
122122

123-
file_path = os.path.join(instance_path, "%i" % time.time())
123+
self._sequence += 1
124+
file_path = os.path.join(instance_path, "%d" % self._sequence)
124125
file_object = open(file_path, "w")
125126

126127
return file_path, file_object

0 commit comments

Comments
 (0)