diff options
-rw-r--r-- | lib/feed2imap/feed2imap.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 250a0e7..77bd48e 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -65,7 +65,13 @@ class Feed2Imap if not File::exist?(@config.cache) @logger.warn("Cache file #{@config.cache} not found, using a new one") else - File::open(@config.cache) { |f| @cache.load(f) } + File::open(@config.cache) do |f| + if not f.flock(File::LOCK_UN) + @logger.fatal("Another instance of feed2imap is already locking the cache file") + exit(1) + end + @cache.load(f) + end end # connecting all IMAP accounts @logger.info('Connecting to IMAP accounts') |