Gitlab Community Edition Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cdstar
pycdstar3
Commits
661ea598
Commit
661ea598
authored
Oct 26, 2019
by
Marcel Hellkamp
Browse files
Refactoring
parent
99100bb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/pycdstar3/api.py
View file @
661ea598
...
...
@@ -14,15 +14,6 @@ from pycdstar3.model import ApiError, JsonObject, FileDownload, FormUpdate
__all__
=
"CDStar"
,
"CDStarVault"
,
"FormUpdate"
,
"ApiError"
def
_fix_filename
(
name
):
# silently strip leading slashes
name
=
name
.
lstrip
(
"/"
)
# Fail hard on relative filenames
if
name
!=
os
.
path
.
normpath
(
name
):
raise
ValueError
(
"Archive file name not in a normalized form: {} != {}"
.
format
(
name
,
os
.
path
.
normpath
(
name
)))
return
name
class
CDStar
:
""" Provide low-level methods for corresponding server-side REST endpoints.
...
...
@@ -350,6 +341,20 @@ class CDStar:
break
def
_fix_filename
(
name
):
""" Normalize a remote archive file path and make sure it makes sense.
Raise if we find relative path segments (likely an error)
"""
# silently strip leading slashes
name
=
name
.
lstrip
(
"/"
)
# Fail hard on relative filenames
if
name
!=
os
.
path
.
normpath
(
name
):
raise
ValueError
(
"Archive file name not in a normalized form: {} != {}"
.
format
(
name
,
os
.
path
.
normpath
(
name
)))
return
name
# Design notes for the following resource handles:
# - The handle instances are really just a slim handle for a remote resource, NOT a wrapper, local copy or cache.
# They should not cache or store anything that might change remotely.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment