diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 44761c3c..e334dbfd 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -125,10 +125,8 @@ jobs: release_name: Release ${{ github.ref }} body: | Changes in this Release - - **ADDED** `version` command showing the current executable version - - **ADDED** `pack` command to create a self contained archive from a folder - - **ADDED** `unpack` command to update a folder from a self contained archive - - **UPDATED** Updated longtail to v0.2.7 + - **FIXED** `--target-path` for `pack` command is now optional + - **FIXED** `--target-path` for `unpack` command is now optional draft: false prerelease: false - name: Download Linux artifacts diff --git a/commands/cmd_pack.go b/commands/cmd_pack.go index 70c256bf..84c0ffeb 100644 --- a/commands/cmd_pack.go +++ b/commands/cmd_pack.go @@ -2,6 +2,8 @@ package commands import ( "context" + "fmt" + "strings" "time" "github.com/DanEngelbrecht/golongtail/longtaillib" @@ -49,6 +51,21 @@ func pack( return storeStats, timeStats, errors.Wrapf(err, fname) } + resolvedTargetPath := "" + if targetFilePath == "" { + urlSplit := strings.Split(longtailutils.NormalizePath(sourceFolderPath), "/") + sourceName := urlSplit[len(urlSplit)-1] + sourceNameSplit := strings.Split(sourceName, ".") + resolvedTargetPath = sourceNameSplit[0] + if resolvedTargetPath == "" { + err = fmt.Errorf("Unable to resolve target path using `%s` as base", sourceFolderPath) + return storeStats, timeStats, errors.Wrap(err, fname) + } + resolvedTargetPath += ".la" + } else { + resolvedTargetPath = targetFilePath + } + fs := longtaillib.CreateFSStorageAPI() defer fs.Dispose() @@ -118,9 +135,9 @@ func pack( createArchiveIndexTime := time.Since(createArchiveIndexStartTime) timeStats = append(timeStats, longtailutils.TimeStat{"Create archive index", createArchiveIndexTime}) - archiveIndexBlockStore := longtaillib.CreateArchiveBlockStoreAPI(fs, targetFilePath, archiveIndex, true) + archiveIndexBlockStore := longtaillib.CreateArchiveBlockStoreAPI(fs, resolvedTargetPath, archiveIndex, true) if !archiveIndexBlockStore.IsValid() { - err = errors.Wrapf(err, "Failed creating archive store for `%s`", targetFilePath) + err = errors.Wrapf(err, "Failed creating archive store for `%s`", resolvedTargetPath) return storeStats, timeStats, errors.Wrapf(err, fname) } defer archiveIndexBlockStore.Dispose() @@ -175,7 +192,7 @@ func pack( type PackCmd struct { SourcePath string `name:"source-path" help:"Source folder path" required:""` SourceIndexPath string `name:"source-index-path" help:"Optional pre-computed index of source-path"` - TargetPath string `name:"target-path" help:"Target file uri" required:""` + TargetPath string `name:"target-path" help:"Target file uri"` TargetChunkSizeOption MaxChunksPerBlockOption TargetBlockSizeOption diff --git a/commands/cmd_unpack.go b/commands/cmd_unpack.go index 05f09768..ec5032e9 100644 --- a/commands/cmd_unpack.go +++ b/commands/cmd_unpack.go @@ -283,7 +283,7 @@ func unpack( type UnpackCmd struct { SourcePath string `name:"source-path" help:"Source folder path" required:""` - TargetPath string `name:"target-path" help:"Target file uri" required:""` + TargetPath string `name:"target-path" help:"Target file uri"` TargetIndexPath string `name:"target-index-path" help:"Optional pre-computed index of target-path"` RetainPermissionsOption ValidateTargetOption