浏览代码

Fix downloaded cache check

Neeraj Gupta 1 年之前
父节点
当前提交
21792a6846
共有 1 个文件被更改,包括 1 次插入2 次删除
  1. 1 2
      pkg/download.go

+ 1 - 2
pkg/download.go

@@ -23,9 +23,8 @@ func (c *ClICtrl) downloadAndDecrypt(
 	dir := c.tempFolder
 	dir := c.tempFolder
 	downloadPath := fmt.Sprintf("%s/%d", dir, file.ID)
 	downloadPath := fmt.Sprintf("%s/%d", dir, file.ID)
 	// check if file exists
 	// check if file exists
-	if _, err := os.Stat(downloadPath); err == nil {
+	if stat, err := os.Stat(downloadPath); err == nil && stat.Size() == file.Info.FileSize {
 		log.Printf("File already exists %s (%s)", file.GetTitle(), utils.ByteCountDecimal(file.Info.FileSize))
 		log.Printf("File already exists %s (%s)", file.GetTitle(), utils.ByteCountDecimal(file.Info.FileSize))
-
 	} else {
 	} else {
 		log.Printf("Downloading %s (%s)", file.GetTitle(), utils.ByteCountDecimal(file.Info.FileSize))
 		log.Printf("Downloading %s (%s)", file.GetTitle(), utils.ByteCountDecimal(file.Info.FileSize))
 		err := c.Client.DownloadFile(ctx, file.ID, downloadPath)
 		err := c.Client.DownloadFile(ctx, file.ID, downloadPath)