Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline import broken by identically-named nested directories #74

Open
Arkanosis opened this issue May 26, 2018 · 4 comments
Open

Pipeline import broken by identically-named nested directories #74

Arkanosis opened this issue May 26, 2018 · 4 comments
Labels
bug User api issue or wrong behavior that need be fixed asap server Issue regarding the server.

Comments

@Arkanosis
Copy link
Member

The pipeline import code can handle both:

  • a zip archive with the pipeline files directly in it;
  • a zip archive with a directory in it that contains the pipeline files.

The latter case is handled by moving the files outside of the directory and then deleting the directory.

Unfortunately, the behavior of shutil.move when the destination already exists consists in moving the source within the destination (ie. as cp does on unices), meaning that if a zip archive contains name/name, then the subdirectory is “moved” into the directory (hence not actually moving). The result is 1) files left in a subdirectory 2) the removal failing because os.rmdir can't remove directories that are not empty.

@ikit
Copy link
Member

ikit commented May 27, 2018

I don't see what you are talking about. Can you cite where it is in the source code ?

@Arkanosis
Copy link
Member Author

I've put links in my report above.

@ikit
Copy link
Member

ikit commented May 27, 2018

ok I understand.
Did you know a better way to manage the both "packaging" strategy ?

@ikit ikit added bug User api issue or wrong behavior that need be fixed asap server Issue regarding the server. labels May 27, 2018
@Arkanosis
Copy link
Member Author

To be honest, I'd rather see a single valid way of packaging pipelines, and that would be without a top directory as it doesn't provide any benefit (the first thing we do when it exists is to remove it). See jar files in Java: there's a single valid place where a manifest can be.

But if we really want to handle that, I guess a sound approach would be to start by renaming the top directory to some name that doesn't exist in it. Something like:

# remove intermediate folder
if zip_root != "":
    new_name = os.path.join(root_path, uuid.uuid4())
    shutil.move(os.path.join(root_path, zip_root), new_name)
    zip_root = new_name
    for filename in os.listdir(zip_root):
        shutil.move(os.path.join(zip_root, filename), os.path.join(root_path, filename))
    os.rmdir(zip_root)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug User api issue or wrong behavior that need be fixed asap server Issue regarding the server.
Projects
None yet
Development

No branches or pull requests

2 participants