updated ui/dist and some lint warnings

This commit is contained in:
Gani Georgiev
2023-07-30 13:40:22 +03:00
parent ac1fd74942
commit bb4a5cfe83
47 changed files with 3421 additions and 3453 deletions
+3 -3
View File
@@ -34,11 +34,11 @@ func MoveDirContent(src string, dest string, rootExclude ...string) error {
moved := map[string]string{}
tryRollback := func() ([]error) {
tryRollback := func() []error {
errs := []error{}
for old, new := range moved {
if err := os.Rename(new, old); err != nil{
if err := os.Rename(new, old); err != nil {
errs = append(errs, err)
}
}
@@ -64,7 +64,7 @@ func MoveDirContent(src string, dest string, rootExclude ...string) error {
new := filepath.Join(dest, basename)
if err := os.Rename(old, new); err != nil {
if errs := tryRollback(); len(errs) > 0 {
if errs := tryRollback(); len(errs) > 0 {
// currently just log the rollback errors
// in the future we may require go 1.20+ to use errors.Join()
log.Println(errs)
+3 -5
View File
@@ -23,7 +23,7 @@ func TestMoveDirContent(t *testing.T) {
// missing dest path
// ---
dir1 := filepath.Join(filepath.Dir(testDir), "a", "b", "c", "d", "_pb_move_dir_content_test_" + security.PseudorandomString(4))
dir1 := filepath.Join(filepath.Dir(testDir), "a", "b", "c", "d", "_pb_move_dir_content_test_"+security.PseudorandomString(4))
defer os.RemoveAll(dir1)
if err := osutils.MoveDirContent(testDir, dir1, exclude...); err == nil {
@@ -32,14 +32,13 @@ func TestMoveDirContent(t *testing.T) {
// existing parent dir
// ---
dir2 := filepath.Join(filepath.Dir(testDir), "_pb_move_dir_content_test_" + security.PseudorandomString(4))
dir2 := filepath.Join(filepath.Dir(testDir), "_pb_move_dir_content_test_"+security.PseudorandomString(4))
defer os.RemoveAll(dir2)
if err := osutils.MoveDirContent(testDir, dir2, exclude...); err != nil {
t.Fatalf("Expected dir2 to be created, got error: %v", err)
}
// find all files
files := []string{}
filepath.WalkDir(dir2, func(path string, d fs.DirEntry, err error) error {
@@ -60,7 +59,7 @@ func TestMoveDirContent(t *testing.T) {
filepath.Join(dir2, "test1"),
filepath.Join(dir2, "a", "a1"),
filepath.Join(dir2, "a", "a2"),
};
}
if len(files) != len(expectedFiles) {
t.Fatalf("Expected %d files, got %d: \n%v", len(expectedFiles), len(files), files)
@@ -91,7 +90,6 @@ func createTestDir(t *testing.T) string {
t.Fatal(err)
}
{
f, err := os.OpenFile(filepath.Join(dir, "test1"), os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {