tags 805224 + upstream patch
forwarded 805224 https://github.com/wking/rss2email/pull/72
thanks

Hi Martin,

Thanks for reporting this bug. I informed upstream of this issue and
prepare a patch. I will upload a fixed version shortly.

Have a nice day!

-- 
Etienne Millon
From 6ce465dac257c29a9f43fe16fd3bafd6a383a445 Mon Sep 17 00:00:00 2001
From: Etienne Millon <m...@emillon.org>
Date: Mon, 23 Nov 2015 20:45:02 +0100
Subject: [PATCH] r2e new: do not overwrite existing config
Bug-Debian: https://bugs.debian.org/805224
Forwarded: https://github.com/wking/rss2email/pull/72

If a configuration file already exists, "r2e new" will overwrite it.
This was reported in the following bug report:

https://bugs.debian.org/805224

This adds a check when running "r2e new" that will exit if the configuration
file already exists.

Signed-off-by: Etienne Millon <m...@emillon.org>
---
 rss2email/command.py | 2 ++
 rss2email/error.py   | 6 ++++++
 rss2email/feeds.py   | 3 +++
 3 files changed, 11 insertions(+)

--- a/rss2email/command.py
+++ b/rss2email/command.py
@@ -31,6 +31,8 @@
     if args.email:
         _LOG.info('set the default target email to {}'.format(args.email))
         feeds.config['DEFAULT']['to'] = args.email
+    if feeds.configfile_exists():
+        raise _error.ConfigAlreadyExistsError(feeds=feeds)
     feeds.save()
 
 def email(feeds, args):
--- a/rss2email/error.py
+++ b/rss2email/error.py
@@ -258,3 +258,9 @@
     def __init__(self, **kwargs):
         message = 'error reading OPML'
         super(OPMLReadError, self).__init__(message=message, **kwargs)
+
+
+class ConfigAlreadyExistsError (FeedsError):
+    def __init__(self, feeds=None):
+        message = 'configuration file already exists'
+        super().__init__(feeds=feeds, message=message)
--- a/rss2email/feeds.py
+++ b/rss2email/feeds.py
@@ -337,6 +337,9 @@
             'cannot convert data file from version {} to {}'.format(
                 version, self.datafile_version))
 
+    def configfile_exists(self):
+        return _os.path.exists(self.configfiles[-1])
+
     def save(self):
         _LOG.debug('save feed configuration to {}'.format(self.configfiles[-1]))
         for feed in self:

Attachment: signature.asc
Description: Digital signature

Reply via email to