share_sub_cache_helper.go 963 B

12345678910111213141516171819202122232425262728293031
  1. package sub_share_center
  2. import (
  3. "github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
  4. "github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
  5. "path/filepath"
  6. )
  7. // CopySub2Cache 检测原有字幕是否存在,然后放到缓存目录中
  8. func CopySub2Cache(orgSubFileFPath string, year int) (bool, string) {
  9. nowFolderDir, err := my_util.GetShareFolderByYear(year)
  10. if err != nil {
  11. log_helper.GetLogger().Errorln("CheckOrgSubFileExistAndCopy2Cache.GetShareFolderByYear", err)
  12. return false, ""
  13. }
  14. desSubFileFPath := filepath.Join(nowFolderDir, filepath.Base(orgSubFileFPath))
  15. err = my_util.CopyFile(orgSubFileFPath, desSubFileFPath)
  16. if err != nil {
  17. log_helper.GetLogger().Errorln("CheckOrgSubFileExistAndCopy2Cache.CopyFile", err)
  18. return false, ""
  19. }
  20. return true, desSubFileFPath
  21. }
  22. // ClearExpiredFiles 情况过期的字幕文件,比如数据库中没有其的引用,那么就需要清理
  23. func ClearExpiredFiles() {
  24. }