From ff3c2f327a57cd59cb3976a1200cc957e85d96cd Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Thu, 26 Jan 2017 13:59:49 -0500 Subject: [PATCH] Check filehash and filename, not just hash when checking if it needs to be saved. (#32) --- README.md | 1 + dbfilestorage/storage.py | 2 +- docs/conf.py | 4 ++-- setup.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 811e4a9..d707c03 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ I will sign everything with 0x769A1BC78A2DDEE2 ## CHANGELOG +- 2017-01-26 [Tyrel Souza] Check filehash and filename, not just hash when checking if it needs to be saved. - 2017-01-25 [Tyrel Souza] Keeping Filename on upload. - 2017-01-23 [Tyrel Souza] Add Modified Time to storage support - 2017-01-23 [Tyrel Souza] Everything should return a "filename" even if it's generated. Make the filename be the hash + ext. (fall back to .txt) diff --git a/dbfilestorage/storage.py b/dbfilestorage/storage.py index 2c6febb..c1b98ce 100644 --- a/dbfilestorage/storage.py +++ b/dbfilestorage/storage.py @@ -63,7 +63,7 @@ class DBFileStorage(Storage): file_ext = ".txt" # create the file, or just return name if the exact file already exists - if not DBFile.objects.filter(pk=filehash).exists(): + if not DBFile.objects.filter(filehash=filehash, name=name).exists(): the_file = DBFile( name=name, filehash=filehash, diff --git a/docs/conf.py b/docs/conf.py index fc2a23c..2fb7b76 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -54,9 +54,9 @@ author = u'Tyrel Souza' # built documents. # # The short X.Y version. -version = u'0.5.1' +version = u'0.5.2' # The full version, including alpha/beta/rc tags. -release = u'0.5.1' +release = u'0.5.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 2f5b913..b6f84db 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ class CleanCommand(Command): setup( name="django-dbfilestorage", - version="0.5.1", + version="0.5.2", description="Database backed file storage for testing.", long_description="Database backed file storage for testing. Stores files as base64 encoded textfields.", author="Tyrel Souza",