Skip to content

Prefix folder path with a slash#56

Merged
martastain merged 3 commits intodevelopfrom
enhancement/prefix_folder_path_with_slash
Nov 24, 2023
Merged

Prefix folder path with a slash#56
martastain merged 3 commits intodevelopfrom
enhancement/prefix_folder_path_with_slash

Conversation

@martastain
Copy link
Copy Markdown
Member

API (both rest and graphql) now returns folder paths prefixed with a slash (as in unix absolute paths).

It is a backward compatible change as everywhere API ACCEPTS a folder path (graphql filters, access control), it allows using both prefixed and unprefixed versions.

@mkolar mkolar requested a review from iLLiCiTiT November 1, 2023 10:28
@martastain martastain added the type: enhancement Improvement of existing functionality or minor addition label Nov 2, 2023
@martastain martastain self-assigned this Nov 2, 2023

async for row in Postgres.iterate(query, transaction=transaction):
parent_path = "/".join(row["path"].split("/")[:-1])
parent_path = "/".join(row["path"].strip("/").split("/")[:-1])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could do the strip above and use the new var later on too:

row_path = row["path"].strip("/")
parent_path = "/".join(row_path.split("/")[:-1]
...
cache[row_path] = attr

@Minkiu
Copy link
Copy Markdown
Contributor

Minkiu commented Nov 7, 2023

I know this is beyond the scope of this PR, but wondered if it might be worth using pathlib.Path for the path (not in the db, but when handling row['path']?

We could then do stuff like:

from pathlib import Path
...
# row["path"] = "/assets/characters/xenomorph"
row_path = Path(row["path"])
row_path.parent # PosixPath('/assets/characters')
row_path.parent.relative_to("/") # PosixPath('assets/characters')
row_path.relative_to("/") # PosixPath('assets/characters/xenomorph')
row_path.as_posix()  # '/assets/characters/xenomorph'

@martastain martastain added this to the 0.6 milestone Nov 15, 2023
@mkolar
Copy link
Copy Markdown
Member

mkolar commented Nov 23, 2023

I believe this has now bee rigorously tested and can be merged now.

@martastain martastain merged commit ac96b90 into develop Nov 24, 2023
@martastain martastain deleted the enhancement/prefix_folder_path_with_slash branch January 11, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants