Unverified Commit d1163cbe authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

Fix lib install --zip-path not preserving folders structure (#1158)

parent 1aa53c88
......@@ -144,17 +144,9 @@ func (lm *LibrariesManager) InstallZipLib(ctx context.Context, archivePath strin
WithField("zip file", archivePath).
Trace("Installing library")
files, err := tmpDir.Join(libraryName).ReadDirRecursive()
files.FilterOutDirs()
for _, f := range files {
finalPath := installPath.Join(f.Base())
if err := finalPath.Parent().MkdirAll(); err != nil {
return fmt.Errorf("creating directory: %w", err)
}
if err := f.CopyTo(finalPath); err != nil {
if err := tmpDir.Join(libraryName).CopyDirTo(installPath); err != nil {
return fmt.Errorf("copying library: %w", err)
}
}
return nil
}
......
......@@ -297,12 +297,26 @@ def test_install_with_zip_path(run_command, data_dir, downloads_dir):
# Verifies library is installed in expected path
assert lib_install_dir.exists()
files = list(lib_install_dir.glob("**/*"))
assert lib_install_dir / "examples" / "SimpleAudioPlayerZero" / "SimpleAudioPlayerZero.ino" in files
assert lib_install_dir / "src" / "AudioZero.h" in files
assert lib_install_dir / "src" / "AudioZero.cpp" in files
assert lib_install_dir / "keywords.txt" in files
assert lib_install_dir / "library.properties" in files
assert lib_install_dir / "README.adoc" in files
# Reinstall library
assert run_command(f"lib install --zip-path {zip_path}")
# Verifies library remains installed
assert lib_install_dir.exists()
files = list(lib_install_dir.glob("**/*"))
assert lib_install_dir / "examples" / "SimpleAudioPlayerZero" / "SimpleAudioPlayerZero.ino" in files
assert lib_install_dir / "src" / "AudioZero.h" in files
assert lib_install_dir / "src" / "AudioZero.cpp" in files
assert lib_install_dir / "keywords.txt" in files
assert lib_install_dir / "library.properties" in files
assert lib_install_dir / "README.adoc" in files
def test_update_index(run_command):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment