Skip to content

Commit

Permalink
Remove Cruft Associated with Root Directory ID = 3
Browse files Browse the repository at this point in the history
Because Gallery used to use physically backed files and was located at
`/gallery-data/root/root` Gallery instances had a root directory with an
ID of 3. This created a need to artificially limit viewing of
directories to require a directory ID of at least 3.

Commit 4682ce6 adds support for S3 and
eliminates the need for the root directory to have a ID of 3 workaround.
This change cleans up that cruft to ease in the setup of future Gallery
instances.

Effort Towards Bug #16
  • Loading branch information
liam-middlebrook committed Dec 30, 2017
1 parent aee7055 commit 06ac9cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gallery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from gallery.models import Tag

from gallery.util import DEFAULT_THUMBNAIL_NAME
from gallery.util import ROOT_DIR_ID
from gallery.util import get_dir_file_contents
from gallery.util import get_dir_tree_dict
from gallery.util import get_full_dir_path
Expand Down Expand Up @@ -377,7 +378,7 @@ def delete_dir(dir_id, auth_dict=None):

if dir_model is None:
return "dir not found", 404
if dir_model.id <= 3:
if dir_model.id <= ROOT_DIR_ID:
return "Permission denied", 403
if not (auth_dict['is_eboard']
or auth_dict['is_rtp']
Expand Down Expand Up @@ -721,8 +722,8 @@ def get_file_parent(file_id):
@gallery_auth
def render_dir(dir_id, auth_dict=None):
dir_id = int(dir_id)
if dir_id < 3:
return redirect('/view/dir/3')
if dir_id < ROOT_DIR_ID:
return redirect('/view/dir/'+ str(ROOT_DIR_ID))

children = display_files(dir_id, internal=True)
dir_model = Directory.query.filter(Directory.id == dir_id).first()
Expand All @@ -733,7 +734,7 @@ def render_dir(dir_id, auth_dict=None):


display_parent = True
if dir_model is None or dir_model.parent is None or dir_id == 3:
if dir_model is None or dir_model.parent is None or dir_id == ROOT_DIR_ID:
display_parent = False
path_stack = []
dir_model_breadcrumbs = dir_model
Expand Down
1 change: 1 addition & 0 deletions gallery/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from gallery.models import File

DEFAULT_THUMBNAIL_NAME = 'reedphoto'
ROOT_DIR_ID = 1

def get_dir_file_contents(dir_id):
contents = [f for f in File.query.filter(File.parent == dir_id).all()]
Expand Down

0 comments on commit 06ac9cf

Please sign in to comment.