Skip to content

Commit

Permalink
Merge pull request #140 from 0chain/fix/path-windows
Browse files Browse the repository at this point in the history
Replace filepath with path package
  • Loading branch information
dabasov authored Nov 29, 2024
2 parents 4864c96 + f66ba99 commit bde4e48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions dstorage/dstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -97,11 +98,14 @@ func (d *DStorageService) Replace(ctx context.Context, remotePath string, r io.R
}

func (d *DStorageService) Upload(ctx context.Context, remotePath string, r io.Reader, size int64, contentType string, isUpdate bool) sdk.OperationRequest {
if !path.IsAbs(remotePath) {
fmt.Println("Remote path is not absolute", remotePath)
}
fileMeta := sdk.FileMeta{
RemotePath: filepath.Clean(remotePath),
RemotePath: path.Clean(remotePath),
ActualSize: size,
MimeType: contentType,
RemoteName: filepath.Base(remotePath),
RemoteName: path.Base(remotePath),
}

opType := constants.FileOperationInsert
Expand Down
12 changes: 6 additions & 6 deletions migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ func InitMigration(mConfig *MigrationConfig) error {
// use client id instead of access token to prevent expiry time
ClientID, ClientSecret := util.GetClientCredentialsFromEnv()
cfg := oauth2.Config{
ClientID: ClientID,
ClientID: ClientID,
ClientSecret: ClientSecret,
Endpoint: oauth2.Endpoint{
AuthURL :"https://accounts.google.com/o/oauth2/auth",
DeviceAuthURL :"https://oauth2.googleapis.com/device/code",
TokenURL :"https://oauth2.googleapis.com/token",
AuthURL: "https://accounts.google.com/o/oauth2/auth",
DeviceAuthURL: "https://oauth2.googleapis.com/device/code",
TokenURL: "https://oauth2.googleapis.com/token",
},
}

token := &oauth2.Token{
AccessToken: util.GetAccessKeyFromEnv(),
AccessToken: util.GetAccessKeyFromEnv(),
RefreshToken: util.GetRefreshKeyFromEnv(),
}

Expand Down Expand Up @@ -459,7 +459,7 @@ func getUniqueShortObjKey(objectKey string) string {
}

func getRemotePath(objectKey string) string {
return filepath.Join(migration.migrateTo, migration.bucket, getUniqueShortObjKey(objectKey))
return path.Join(migration.migrateTo, migration.bucket, getUniqueShortObjKey(objectKey))
}

func checkIsFileExist(ctx context.Context, downloadObj *DownloadObjectMeta) error {
Expand Down

0 comments on commit bde4e48

Please sign in to comment.