Skip to content

Commit

Permalink
refactoring : renaming packages
Browse files Browse the repository at this point in the history
  • Loading branch information
watermint committed Sep 19, 2022
1 parent 68e6020 commit 4eac03a
Show file tree
Hide file tree
Showing 30 changed files with 117 additions and 118 deletions.
4 changes: 2 additions & 2 deletions catalogue/message.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_util"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"github.com/watermint/toolbox/domain/dropbox/model/mo_path"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package filesystem
package dbx_fs

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client_impl"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dfs_copier_batch
package dbx_fs_copier_batch

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
"github.com/watermint/toolbox/domain/dropbox/api/dbx_util"
"github.com/watermint/toolbox/domain/dropbox/filesystem"
"github.com/watermint/toolbox/domain/dropbox/filesystem/dbx_fs"
"github.com/watermint/toolbox/essentials/api/api_request"
"github.com/watermint/toolbox/essentials/file/es_filesystem"
"github.com/watermint/toolbox/essentials/io/es_block"
Expand Down Expand Up @@ -71,7 +71,7 @@ func (z *copierLocalToDropboxBatch) Shutdown() (err es_filesystem.FileSystemErro
l.Debug("Shutdown sessions")
if sErr := z.sessions.Shutdown(); sErr != nil {
l.Debug("There was an error during shutdown", esl.Error(sErr))
return filesystem.NewError(sErr)
return dbx_fs.NewError(sErr)
}
return nil
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func (z *copierLocalToDropboxBatch) Copy(source es_filesystem.Entry, target es_f
cp := es_filesystem.NewCopyPair(source, target)

localPath := source.Path().Path()
targetDbxPath, dbxErr := filesystem.ToDropboxPath(target)
targetDbxPath, dbxErr := dbx_fs.ToDropboxPath(target)
if dbxErr != nil {
l.Debug("unable to convert to Dropbox path", esl.Error(dbxErr))
onFailure(cp, dbxErr)
Expand Down Expand Up @@ -147,7 +147,7 @@ func (z *copierLocalToDropboxBatch) Copy(source es_filesystem.Entry, target es_f
l = l.With(esl.String("sessionId", sessionId))
if sesErr != nil {
l.Debug("Unable to start an upload session", esl.Error(sesErr))
onFailure(cp, filesystem.NewError(sesErr))
onFailure(cp, dbx_fs.NewError(sesErr))
z.backlogCount.Done()
return
}
Expand All @@ -156,7 +156,7 @@ func (z *copierLocalToDropboxBatch) Copy(source es_filesystem.Entry, target es_f
offsets, fsErr := z.fs.FileBlocks(localPath)
if fsErr != nil {
l.Debug("Unable to retrieve file info", esl.Error(fsErr))
onFailure(cp, filesystem.NewError(fsErr))
onFailure(cp, dbx_fs.NewError(fsErr))
z.backlogCount.Done()
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dfs_copier_batch
package dbx_fs_copier_batch

const (
queueIdBlockCommit = "upload_commit"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dfs_copier_batch
package dbx_fs_copier_batch

import (
"errors"
"github.com/watermint/toolbox/domain/dropbox/api/dbx_async"
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
"github.com/watermint/toolbox/domain/dropbox/api/dbx_error"
"github.com/watermint/toolbox/domain/dropbox/filesystem"
"github.com/watermint/toolbox/domain/dropbox/filesystem/dbx_fs"
"github.com/watermint/toolbox/domain/dropbox/model/mo_file"
"github.com/watermint/toolbox/essentials/api/api_request"
"github.com/watermint/toolbox/essentials/file/es_filesystem"
Expand Down Expand Up @@ -127,7 +127,7 @@ func (z *copierBatchSessions) FinishBatchCommit(batch *FinishBatch) {
z.sessionIdToMutex.Lock()
for _, sid := range deadSessionId {
if cb, ok := z.sessionIdToCallback[sid]; ok {
cb.OnFailure(cb.CopyPair, filesystem.NewError(errors.New("unable to find upload session id")))
cb.OnFailure(cb.CopyPair, dbx_fs.NewError(errors.New("unable to find upload session id")))
} else {
l.Error("Unable to find upload session id", esl.String("sessionId", sid))
}
Expand All @@ -145,7 +145,7 @@ func (z *copierBatchSessions) FinishBatchCommit(batch *FinishBatch) {
z.sessionIdToMutex.Lock()
for _, e := range p.Entries {
if cb, ok := z.sessionIdToCallback[e.Cursor.SessionId]; ok {
cb.OnFailure(cb.CopyPair, filesystem.NewError(err))
cb.OnFailure(cb.CopyPair, dbx_fs.NewError(err))
} else {
l.Debug("Callback not found", esl.String("sessionId", e.Cursor.SessionId))
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func (z *copierBatchSessions) FinishBatchCommit(batch *FinishBatch) {
reason := resEntryJson.RawString() // TODO: change it more better way to extract message
if cb, ok := z.sessionIdToCallback[sid]; ok {
ll.Debug("Error on finish batch")
cb.OnFailure(cb.CopyPair, filesystem.NewError(errors.New(reason)))
cb.OnFailure(cb.CopyPair, dbx_fs.NewError(errors.New(reason)))
} else {
ll.Debug("Callback not found")
}
Expand All @@ -196,14 +196,14 @@ func (z *copierBatchSessions) FinishBatchCommit(batch *FinishBatch) {
ll.Debug("Unable to unmarshal metadata", esl.Error(err))
if cb, ok := z.sessionIdToCallback[sid]; ok {
ll.Debug("Error on finish batch")
cb.OnFailure(cb.CopyPair, filesystem.NewError(err))
cb.OnFailure(cb.CopyPair, dbx_fs.NewError(err))
} else {
ll.Debug("Callback not found")
}
} else {
if cb, ok := z.sessionIdToCallback[sid]; ok {
ll.Debug("Success entry", esl.Any("entry", entryMeta))
cb.OnSuccess(cb.CopyPair, filesystem.NewEntry(entryMeta))
cb.OnSuccess(cb.CopyPair, dbx_fs.NewEntry(entryMeta))
} else {
ll.Debug("Callback not found")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dfs_copier_batch
package dbx_fs_copier_batch

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dfs_copier_dbx_to_dbx
package dbx_fs_copier_dbx_to_dbx

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
"github.com/watermint/toolbox/domain/dropbox/filesystem"
"github.com/watermint/toolbox/domain/dropbox/filesystem/dbx_fs"
"github.com/watermint/toolbox/domain/dropbox/service/sv_file_relocation"
"github.com/watermint/toolbox/essentials/file/es_filesystem"
"github.com/watermint/toolbox/essentials/log/esl"
Expand All @@ -28,14 +28,14 @@ func (z copierDropboxToDropboxSingle) Copy(source es_filesystem.Entry, target es
l.Debug("Copy")
cp := es_filesystem.NewCopyPair(source, target)

sourceDbxPath, err := filesystem.ToDropboxPath(source.Path())
sourceDbxPath, err := dbx_fs.ToDropboxPath(source.Path())
if err != nil {
l.Debug("unable to convert to Dropbox path", esl.Error(err))
onFailure(cp, err)
return
}

targetDbxPath, err := filesystem.ToDropboxPath(target)
targetDbxPath, err := dbx_fs.ToDropboxPath(target)
if err != nil {
l.Debug("unable to convert to Dropbox path", esl.Error(err))
onFailure(cp, err)
Expand All @@ -50,7 +50,7 @@ func (z copierDropboxToDropboxSingle) Copy(source es_filesystem.Entry, target es
}

l.Debug("successfully copied", esl.Any("entry", dbxEntry.Concrete()))
onSuccess(cp, filesystem.NewEntry(dbxEntry))
onSuccess(cp, dbx_fs.NewEntry(dbxEntry))
}

func (z copierDropboxToDropboxSingle) Shutdown() (err es_filesystem.FileSystemError) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dfs_dbx_to_local
package dbx_fs_dbx_to_local

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
"github.com/watermint/toolbox/domain/dropbox/filesystem"
"github.com/watermint/toolbox/domain/dropbox/filesystem/dbx_fs"
"github.com/watermint/toolbox/domain/dropbox/service/sv_file_content"
"github.com/watermint/toolbox/essentials/file/es_filesystem"
"github.com/watermint/toolbox/essentials/file/es_filesystem_local"
Expand Down Expand Up @@ -32,7 +32,7 @@ func (z copierDropboxToLocal) Copy(source es_filesystem.Entry, target es_filesys
l.Debug("Copy (download)")
cp := es_filesystem.NewCopyPair(source, target)

sourcePath, err := filesystem.ToDropboxPath(source.Path())
sourcePath, err := dbx_fs.ToDropboxPath(source.Path())
if err != nil {
l.Debug("Unable to convert path format", esl.Error(err))
onFailure(cp, err)
Expand All @@ -42,15 +42,15 @@ func (z copierDropboxToLocal) Copy(source es_filesystem.Entry, target es_filesys
downloadUrl, dbxErr := sv_file_content.NewDownload(z.ctx).DownloadUrl(sourcePath)
if dbxErr != nil {
l.Debug("Unable to download", esl.Error(dbxErr))
onFailure(cp, filesystem.NewError(dbxErr))
onFailure(cp, dbx_fs.NewError(dbxErr))
return
}
l.Debug("Download url", esl.String("url", downloadUrl))

dlErr := es_download.Download(l, downloadUrl, target.Path())
if dlErr != nil {
l.Debug("Download failure", esl.Error(dlErr))
onFailure(cp, filesystem.NewError(dlErr))
onFailure(cp, dbx_fs.NewError(dlErr))
return
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dfs_dbx_to_local_block
package dbx_fs_dbx_to_local_block

import (
"encoding/json"
Expand All @@ -8,7 +8,7 @@ import (
"github.com/vbauerster/mpb/v5/decor"
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
"github.com/watermint/toolbox/domain/dropbox/api/dbx_request"
"github.com/watermint/toolbox/domain/dropbox/filesystem"
"github.com/watermint/toolbox/domain/dropbox/filesystem/dbx_fs"
"github.com/watermint/toolbox/essentials/ambient/ea_indicator"
"github.com/watermint/toolbox/essentials/api/api_request"
"github.com/watermint/toolbox/essentials/collections/es_number"
Expand Down Expand Up @@ -63,27 +63,27 @@ func (z *copierDropboxToLocal) Copy(source es_filesystem.Entry, target es_filesy
q, err := dbx_request.DropboxApiArg(p)
if err != nil {
l.Debug("Unable to create path arg", esl.Error(err))
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
return
}

res := z.ctx.ContentHead("files/download", q)
if err, fail := res.Failure(); fail {
l.Debug("Head request failure", esl.Error(err))
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
return
}

if h := res.Header("Accept-Ranges"); h != "bytes" {
l.Debug("The server does not support range request", esl.String("acceptRanges", h))
onFailure(pair, filesystem.NewError(ErrorRangeRequestNotSupported))
onFailure(pair, dbx_fs.NewError(ErrorRangeRequestNotSupported))
return
}

contentLength := es_number.New(res.Header("Content-Length"))
if !contentLength.IsInt() {
l.Debug("invalid content length", esl.String("contentLength", res.Header("Content-Length")))
onFailure(pair, filesystem.NewError(ErrorInvalidContentLength))
onFailure(pair, dbx_fs.NewError(ErrorInvalidContentLength))
return
}

Expand All @@ -93,7 +93,7 @@ func (z *copierDropboxToLocal) Copy(source es_filesystem.Entry, target es_filesy
f, err := os.Create(target.Path())
if err != nil {
l.Debug("Unable to create the file", esl.Error(err))
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
} else {
_ = f.Close()
if entry, fsErr := z.target.Info(target); fsErr != nil {
Expand All @@ -109,22 +109,22 @@ func (z *copierDropboxToLocal) Copy(source es_filesystem.Entry, target es_filesy
j, err := es_json.ParseString(resHeader)
if err != nil {
l.Debug("Unable to parse response header", esl.Error(err), esl.String("header", resHeader))
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
return
}

apiResult := &DownloadHeadResponse{}
if err := j.Model(apiResult); err != nil {
l.Debug("Unable to parse response header", esl.Error(err), esl.String("header", resHeader))
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
return
}

revP := &P{Path: "rev:" + apiResult.Rev}
revQ, err := dbx_request.DropboxApiArg(revP)
if err != nil {
l.Debug("Unable to create path arg", esl.Error(err))
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
return
}

Expand Down Expand Up @@ -153,7 +153,7 @@ func (z *copierDropboxToLocal) Copy(source es_filesystem.Entry, target es_filesy
}

}, func(w es_block.BlockWriter, offset int64, err error) {
onFailure(pair, filesystem.NewError(err))
onFailure(pair, dbx_fs.NewError(err))
},
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dfs_local_to_dbx
package dbx_fs_local_to_dbx

import (
"github.com/watermint/toolbox/domain/dropbox/api/dbx_client"
"github.com/watermint/toolbox/domain/dropbox/filesystem"
"github.com/watermint/toolbox/domain/dropbox/filesystem/dbx_fs"
"github.com/watermint/toolbox/domain/dropbox/service/sv_file_content"
"github.com/watermint/toolbox/essentials/file/es_filesystem"
"github.com/watermint/toolbox/essentials/log/esl"
Expand Down Expand Up @@ -30,7 +30,7 @@ func (z copierLocalToDropbox) Copy(source es_filesystem.Entry, target es_filesys
l.Debug("Copy (upload)")
cp := es_filesystem.NewCopyPair(source, target)

targetDbxPath, err := filesystem.ToDropboxPath(target.Ancestor())
targetDbxPath, err := dbx_fs.ToDropboxPath(target.Ancestor())
if err != nil {
l.Debug("unable to convert to Dropbox path", esl.Error(err))
onFailure(cp, err)
Expand All @@ -41,12 +41,12 @@ func (z copierLocalToDropbox) Copy(source es_filesystem.Entry, target es_filesys
dbxEntry, dbxErr := svc.Overwrite(targetDbxPath, source.Path().Path())
if dbxErr != nil {
l.Debug("Unable to upload file", esl.Error(dbxErr))
onFailure(cp, filesystem.NewError(dbxErr))
onFailure(cp, dbx_fs.NewError(dbxErr))
return
}

l.Debug("successfully uploaded", esl.Any("entry", dbxEntry.Concrete()))
onSuccess(cp, filesystem.NewEntry(dbxEntry))
onSuccess(cp, dbx_fs.NewEntry(dbxEntry))
}

func (z copierLocalToDropbox) Shutdown() (err es_filesystem.FileSystemError) {
Expand Down
Loading

0 comments on commit 4eac03a

Please sign in to comment.