Sfoglia il codice sorgente

lockfile in new subfolder

Guénaël Muller 7 anni fa
parent
commit
85bc675961

+ 1 - 1
tracim/development.ini.base Vedi File

@@ -230,7 +230,7 @@ email.reply.use_html_parsing = true
230 230
 email.reply.use_txt_parsing = true
231 231
 # Lockfile path is required for email_reply feature,
232 232
 # it's just an empty file use to prevent concurrent access to imap unseen mail
233
-email.reply.lockfile_path = %(here)s/email_fetcher.lock
233
+email.reply.lockfile_path = %(here)s/tmp/email_fetcher.lock
234 234
 
235 235
 ## Radical (CalDav server) configuration
236 236
 # radicale.server.host = 0.0.0.0

+ 1 - 1
tracim/tracim/config/app_cfg.py Vedi File

@@ -394,7 +394,7 @@ class CFG(object):
394 394
         ))
395 395
         self.EMAIL_REPLY_LOCKFILE_PATH = tg.config.get(
396 396
             'email.reply.lockfile_path',
397
-            '/tmp/tracim_email_fetcher.lock'
397
+            '/tmp/tracim/email_fetcher.lock'
398 398
         )
399 399
 
400 400
         self.TRACKER_JS_PATH = tg.config.get(

+ 8 - 1
tracim/tracim/lib/email_fetcher.py Vedi File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
+import os
3 4
 import time
4 5
 import imaplib
5 6
 import json
@@ -188,9 +189,15 @@ class MailFetcher(object):
188 189
         self.token = token
189 190
         self.use_html_parsing = use_html_parsing
190 191
         self.use_txt_parsing = use_txt_parsing
191
-        self.lock = filelock.FileLock(lockfile_path)
192
+        self._set_lock(lockfile_path)
192 193
         self._is_active = True
193 194
 
195
+    def _set_lock(self, lockfile_path):
196
+        dir_path = os.path.dirname(lockfile_path)
197
+        if dir_path:
198
+            os.makedirs(dir_path, exist_ok=True)
199
+        self.lock = filelock.FileLock(lockfile_path)
200
+
194 201
     def run(self) -> None:
195 202
         logger.info(self, 'Starting MailFetcher')
196 203
         while self._is_active: