summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-07-07 00:34:55 +0800
committerKeuin <[email protected]>2023-07-07 00:34:55 +0800
commit7fd817f6d1ead3de85294c1893a6e1572a1d12e3 (patch)
tree38b9f13104fe208449b679a2b77959dea5ab1b4e
parent6eb5a7af48d04adc5625cbc8355e2556db4b992f (diff)
Refactor: move file operations into single package.
-rw-r--r--bilibili/streaming.go4
-rw-r--r--common/files/bytesize.go (renamed from common/bytesize.go)2
-rw-r--r--common/files/bytesize_test.go (renamed from common/bytesize_test.go)2
-rw-r--r--common/files/filename.go (renamed from common/filename.go)2
-rw-r--r--recording/runner.go6
5 files changed, 8 insertions, 8 deletions
diff --git a/bilibili/streaming.go b/bilibili/streaming.go
index b985bbb..9f74950 100644
--- a/bilibili/streaming.go
+++ b/bilibili/streaming.go
@@ -5,7 +5,7 @@ import (
"errors"
"fmt"
errs "github.com/keuin/slbr/bilibili/errors"
- "github.com/keuin/slbr/common"
+ "github.com/keuin/slbr/common/files"
"io"
"net/http"
"os"
@@ -106,6 +106,6 @@ copyLoop:
b.logger.Error("Stream copying was interrupted unexpectedly: %v", err)
}
- b.logger.Info("Total downloaded: %v", common.PrettyBytes(uint64(n)))
+ b.logger.Info("Total downloaded: %v", files.PrettyBytes(uint64(n)))
return err
}
diff --git a/common/bytesize.go b/common/files/bytesize.go
index 9b3aa97..95f857a 100644
--- a/common/bytesize.go
+++ b/common/files/bytesize.go
@@ -1,4 +1,4 @@
-package common
+package files
import "fmt"
diff --git a/common/bytesize_test.go b/common/files/bytesize_test.go
index b68ee4c..970c242 100644
--- a/common/bytesize_test.go
+++ b/common/files/bytesize_test.go
@@ -1,4 +1,4 @@
-package common
+package files
import (
"testing"
diff --git a/common/filename.go b/common/files/filename.go
index aedd377..725563c 100644
--- a/common/filename.go
+++ b/common/files/filename.go
@@ -1,4 +1,4 @@
-package common
+package files
import "fmt"
diff --git a/recording/runner.go b/recording/runner.go
index d43f451..13a4050 100644
--- a/recording/runner.go
+++ b/recording/runner.go
@@ -12,7 +12,7 @@ import (
"fmt"
"github.com/keuin/slbr/bilibili"
errs "github.com/keuin/slbr/bilibili/errors"
- "github.com/keuin/slbr/common"
+ "github.com/keuin/slbr/common/files"
"github.com/keuin/slbr/common/myurl"
"github.com/keuin/slbr/logging"
"github.com/samber/mo"
@@ -298,7 +298,7 @@ func record(
}
baseName := GenerateFileName(profile.Data.Title, time.Now())
- fileName := common.CombineFileName(baseName, extName)
+ fileName := files.CombineFileName(baseName, extName)
saveDir := task.Download.SaveDirectory
filePath := path.Join(saveDir, fileName)
@@ -315,7 +315,7 @@ func record(
return
}
from := filePath
- to := path.Join(saveDir, common.CombineFileName(baseName, originalExtName))
+ to := path.Join(saveDir, files.CombineFileName(baseName, originalExtName))
err := os.Rename(from, to)
if err != nil {
logger.Error("Cannot rename %v to %v: %v", from, to, err)