Skip to content

Commit

Permalink
Properly checking name of file
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhade3 committed Nov 25, 2020
1 parent d94c7af commit 997ab49
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ func getArchive(body []byte, date string, keywordFile string, outfile string) {
color.Cyan(fullname + " Archive already exists!")
} else {
for _, item := range dump_files.File {
dump_filepath := filepath.Join("archives", fullname, item.DumpType, "______.txt")
_ = os.Remove(dump_filepath)
dump_filepath, _ := filepath.Glob(filepath.Join("archives", fullname, item.DumpType, "*.txt"))
if len(dump_filepath) > 0{
_ = os.Remove(dump_filepath[0])
}

if fileExists(filepath.Join("archives", fullname, item.Name)) == false {
color.Red(item.Name + " doesn't exist locally.")
Expand All @@ -165,9 +167,10 @@ func getArchive(body []byte, date string, keywordFile string, outfile string) {

color.Cyan("Decompressing XZ Archives..")
for _, item := range dump_files.File {
tarfile := filepath.Join("archives", fullname, item.DumpType, "______.txt.xz")
_, err := exec.Command("xz", "--decompress", tarfile).Output()
tarfile, _ := filepath.Glob(filepath.Join("archives", fullname, item.DumpType, "*.txt.xz"))
_, err := exec.Command("xz", "--decompress", tarfile[0]).Output()
if err != nil {
fmt.Println(err)
panic(err)
}
}
Expand All @@ -187,8 +190,8 @@ func getArchive(body []byte, date string, keywordFile string, outfile string) {
continue
}
for _, item := range dump_files.File {
dump_path := filepath.Join("archives", fullname, item.DumpType, "______.txt")
searchFile(dump_path, keywordSlice[i], outfile)
dump_path, _ := filepath.Glob(filepath.Join("archives", fullname, item.DumpType, "*.txt"))
searchFile(dump_path[0], keywordSlice[i], outfile)
}
}

Expand Down

0 comments on commit 997ab49

Please sign in to comment.