Skip to content

Commit 870b781

Browse files
committed
fix error in init mode && Add unarchive logs
Signed-off-by: Zemtsov Vladimir <vl.zemtsov@gmail.com>
1 parent c9e7b07 commit 870b781

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
### Added
22

3+
### Release v0.0.4
4+
- Fix: fix error in init mode
5+
- Logging: Add unarchive logs
6+
37
### Release v0.0.3
48
- Fix: Fix checks for webhook in initMode
59

610
### Release v0.0.2
7-
811
- Cleanup: Add automatically tag image before push in Makefile
912
- Cleanup: Fix usage in ReadMe
1013
- Cleanup: Fix error with CHANGELOG name file

internal/app/app.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func Run(cfg *config.Config) error {
2929
}
3030
if len(cfg.VolumeDirsArchive) > 0 {
3131
for _, vda := range cfg.VolumeDirsArchive {
32+
fmt.Printf("VDA: %s\n", vda)
3233
unarchiveDir(vda, cfg)
3334
}
3435
if *cfg.InitMode {
@@ -103,7 +104,7 @@ func volumeDirArchiveWatcher(cfg *config.Config) error {
103104
continue
104105
}
105106

106-
err := unarchiveFile(event.Name, cfg)
107+
err := unarchiveDir(event.Name, cfg)
107108
if err != nil {
108109
log.Println("Error:", err)
109110
}
@@ -214,13 +215,15 @@ func sendWebHook(cfg *config.Config) {
214215
}
215216

216217
func unarchiveDir(path string, cfg *config.Config) error {
217-
files, err := ioutil.ReadDir(path)
218+
kuberPath := path + "/..data"
219+
files, err := ioutil.ReadDir(kuberPath)
218220
if err != nil {
219221
return err
220222
}
221223

222224
for _, file := range files {
223225
fullFilePath := path + "/" + file.Name()
226+
fmt.Printf("file: %s", fullFilePath)
224227
err := unarchiveFile(fullFilePath, cfg)
225228
if err != nil {
226229
return err
@@ -230,6 +233,8 @@ func unarchiveDir(path string, cfg *config.Config) error {
230233
}
231234

232235
func unarchiveFile(path string, cfg *config.Config) error {
236+
outFileName := *cfg.DirForUnarchive + "/" + filepath.Base(path)[0:len(filepath.Base(path))-3]
237+
log.Printf("Unarhive file from %s to %s", path, outFileName)
233238

234239
if path[len(path)-3:] != ".gz" {
235240
return fmt.Errorf("File %s is not a .gz archive. Do nothing", path)
@@ -247,9 +252,6 @@ func unarchiveFile(path string, cfg *config.Config) error {
247252
defer gzipReader.Close()
248253

249254
// Uncompress to a writer. We'll use a file writer
250-
outFileName := *cfg.DirForUnarchive + "/" + filepath.Base(path)[0:len(filepath.Base(path))-3]
251-
// fmt.Println(outFileName)
252-
253255
outfileWriter, err := os.Create(outFileName)
254256
if err != nil {
255257
return err

0 commit comments

Comments
 (0)