Commit b84b6a2d authored by Sandeep S. Shewalkar's avatar Sandeep S. Shewalkar
Browse files

Merge branch 'DevBranch' into 'stagingbranch'

Update fileutil.go

See merge request !16
parents afd76128 4cda9273
2 merge requests!17Stagingbranch,!16Update fileutil.go
Showing with 8 additions and 5 deletions
......@@ -61,13 +61,15 @@ func mergeFiles(filename string, count int) {
fmt.Println("temp file name : " + tempFilename)
fmt.Println("file name : " + filename)
file, err := os.OpenFile(DownloadLocation+"/"+tempFilename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
log.Fatal(err)
}
defer file.Close()
for i := 0; i < count; i++ {
partFilename := DownloadLocation + "/temp/" + filename + "_" + strconv.Itoa(i)
file, err := os.OpenFile(DownloadLocation+"/"+tempFilename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
log.Fatal(err)
}
defer file.Close()
reader, err := ioutil.ReadFile(partFilename)
reader = reader[16:]
if err != nil {
......@@ -77,6 +79,7 @@ func mergeFiles(filename string, count int) {
log.Fatal(err)
}
}
file.Close()
os.Rename(DownloadLocation+"/"+tempFilename, DownloadLocation+"/"+filename)
}
func isDirEmpty(name string) (bool, error) {
......
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