Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
feature: delete unused function for passing CI
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <[email protected]>
  • Loading branch information
starnop committed May 29, 2019
1 parent 8bd5534 commit b5beae1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
5 changes: 0 additions & 5 deletions supernode/daemon/mgr/cdn/path_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ import (
"github.com/dragonflyoss/Dragonfly/supernode/store"
)

var getDownloadKeyFunc = getDownloadKey
var getMetaDataKeyFunc = getMetaDataKey
var getMd5DataKeyFunc = getMd5DataKey
var getUploadKeyFunc = getUploadKey
var getDownloadRawFunc = getDownloadRaw
var getMetaDataRawFunc = getMetaDataRaw
var getMd5DataRawFunc = getMd5DataRaw
var getUploadRawFunc = getUploadRaw

func getDownloadKey(taskID string) string {
return path.Join(cutil.SubString(taskID, 0, 3), taskID)
Expand Down
18 changes: 4 additions & 14 deletions supernode/daemon/mgr/cdn/super_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ import (
"github.com/dragonflyoss/Dragonfly/supernode/store"

"github.com/go-check/check"
"github.com/prashantv/gostub"
)

type SuperWriterTestSuite struct {
workHome string
config string
writer *superWriter
downloadPathStub *gostub.Stubs
workHome string
config string
writer *superWriter
}

func init() {
Expand All @@ -49,13 +47,9 @@ func (s *SuperWriterTestSuite) SetUpSuite(c *check.C) {
fileStore, err := store.NewStore(store.LocalStorageDriver, store.NewLocalStorage, s.config)
c.Check(err, check.IsNil)
s.writer = newSuperWriter(fileStore, nil)

s.downloadPathStub = gostub.Stub(&getDownloadKeyFunc, getDownloadKeyFuncMock)
}

func (s *SuperWriterTestSuite) TearDownSuite(c *check.C) {
s.downloadPathStub.Reset()

if s.workHome != "" {
if err := os.RemoveAll(s.workHome); err != nil {
fmt.Printf("remove path: %s error", s.workHome)
Expand Down Expand Up @@ -107,12 +101,8 @@ func (s *SuperWriterTestSuite) TestWriteToFile(c *check.C) {
func checkFileSize(cdnStore *store.Store, taskID string, expectedSize int64, c *check.C) {
storageInfo, err := cdnStore.Stat(context.TODO(), &store.Raw{
Bucket: config.DownloadHome,
Key: getDownloadKeyFuncMock(taskID),
Key: getDownloadKey(taskID),
})
c.Check(err, check.IsNil)
c.Check(storageInfo.Size, check.Equals, expectedSize)
}

func getDownloadKeyFuncMock(taskID string) string {
return taskID
}
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/cdn/super_writer_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (cw *superWriter) writeToFile(ctx context.Context, bytesBuffer *bytes.Buffe
// write to the storage
return cw.cdnStore.Put(ctx, &store.Raw{
Bucket: config.DownloadHome,
Key: getDownloadKeyFunc(taskID),
Key: getDownloadKey(taskID),
Offset: int64(pieceNum) * int64(PieceSize),
}, resultBuf)
}
9 changes: 6 additions & 3 deletions supernode/daemon/mgr/cdn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import (
// operates on the underlying files stored on the local disk, etc.
type CDNMgr interface {
// TriggerCDN will trigger CDN to download the file from sourceUrl.
// In common, it will including the following steps:
// It will including the following steps:
// 1). download the source file
// 2). update the taskInfo
// 3). write the file to disk
// 2). write the file to disk
//
// In fact, it's a very time consuming operation.
// So if not necessary, it should usually be executed concurrently.
// In addition, it's not thread-safe.
TriggerCDN(ctx context.Context, taskInfo *types.TaskInfo) (*types.TaskInfo, error)

// GetStatus get the status of the file.
Expand Down

0 comments on commit b5beae1

Please sign in to comment.