From bea2a7dd623f7041b3d4855373cb149174f1073c Mon Sep 17 00:00:00 2001 From: Eugen Ciur Date: Thu, 4 Mar 2021 09:34:50 +0100 Subject: [PATCH] Reset version to 0 for newly created documents "from paste" --- changelog.md | 4 ++++ mglib/storage.py | 12 ++++++++++-- setup.cfg | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 23b69b8..9faa3b4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ # Changelog +## [1.3.8] - 4 March 2020 + +- bug fix: reset version to 0 for newly created documents "from paste" + ## [1.3.5] - 14 December 2020 ### Changed diff --git a/mglib/storage.py b/mglib/storage.py index 9a90c44..75999b5 100644 --- a/mglib/storage.py +++ b/mglib/storage.py @@ -391,9 +391,17 @@ class Storage: from src_doc_path. Both dest and src are instances of mglib.path.DocumentPath """ + next_version = 0 + if dest_doc_is_new: + # document is new, start version with 0 + next_version = 0 + else: + # destination document is not new, increment its version + next_version = dest_doc_path.version + 1 + next_ver_dp = DocumentPath.copy_from( dest_doc_path, - version=dest_doc_path.version + 1 + version=next_version ) self.make_sure_path_exists( self.abspath(next_ver_dp) @@ -448,7 +456,7 @@ class Storage: ) dest_page_num += 1 - return dest_doc_path.version + 1 + return next_version class FileSystemStorage(Storage): diff --git a/setup.cfg b/setup.cfg index 1ab185a..9ff344e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = mglib -version = 1.3.7 +version = 1.3.8 description = Common code used across all Papermerge project utilities long_description = file: README.rst url = https://www.papermerge.com/