Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e9625733d | ||
|
|
1513d76ca9 | ||
|
|
87dc0bf80e | ||
|
|
69c0d33543 | ||
|
|
8d891755e0 | ||
|
|
a9cd7869eb | ||
|
|
c40ab338a3 | ||
|
|
0fcd10d793 | ||
|
|
b7b75c5f46 | ||
|
|
b97b7b8987 | ||
|
|
8f3d514e3b | ||
|
|
bb3c0d45f2 | ||
|
|
9ebde383d4 | ||
|
|
cfea4fdc75 |
+167
@@ -0,0 +1,167 @@
|
||||
project_name: mc
|
||||
|
||||
release:
|
||||
name_template: "Version {{.Version}}"
|
||||
disable: true
|
||||
github:
|
||||
owner: minio
|
||||
name: mc
|
||||
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
- GO111MODULE=on
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- make clean
|
||||
- go generate ./...
|
||||
- go mod tidy
|
||||
- go mod download
|
||||
|
||||
builds:
|
||||
-
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
- freebsd
|
||||
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- arm
|
||||
- ppc64le
|
||||
- s390x
|
||||
|
||||
goarm:
|
||||
- 7
|
||||
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
- goos: darwin
|
||||
goarch: ppc64le
|
||||
- goos: darwin
|
||||
goarch: s390x
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: windows
|
||||
goarch: ppc64le
|
||||
- goos: windows
|
||||
goarch: s390x
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
- goos: freebsd
|
||||
goarch: arm64
|
||||
- goos: freebsd
|
||||
goarch: ppc64le
|
||||
- goos: freebsd
|
||||
goarch: s390x
|
||||
|
||||
flags:
|
||||
- -tags=kqueue
|
||||
- -trimpath
|
||||
|
||||
ldflags:
|
||||
- "-s -w -X github.com/minio/mc/cmd.Version={{.Version}} -X github.com/minio/mc/cmd.ReleaseTag={{.Tag}} -X github.com/minio/mc/cmd.CommitID={{.FullCommit}} -X github.com/minio/mc/cmd.ShortCommitID={{.ShortCommit}}"
|
||||
|
||||
archives:
|
||||
-
|
||||
format: binary
|
||||
name_template: "{{ .Binary }}-release/{{ .Os }}-{{ .Arch }}/{{ .Binary }}.{{ .Version }}"
|
||||
|
||||
nfpms:
|
||||
-
|
||||
id: minio
|
||||
package_name: mc
|
||||
vendor: MinIO, Inc.
|
||||
homepage: https://min.io/
|
||||
maintainer: dev@min.io
|
||||
description: MinIO Client (mc) provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff, find etc. It supports filesystems and Amazon S3 compatible cloud storage service (AWS Signature v2 and v4).
|
||||
license: Apache 2.0
|
||||
bindir: /usr/bin
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
overrides:
|
||||
deb:
|
||||
file_name_template: "{{ .Binary }}-release/debs/{{ .ProjectName }}-{{ .Version }}_{{ .Arch }}"
|
||||
replacements:
|
||||
arm: armv7
|
||||
files:
|
||||
"NOTICE": "/usr/share/mc/NOTICE"
|
||||
"CREDITS": "/usr/share/mc/CREDITS"
|
||||
"LICENSE": "/usr/share/mc/LICENSE"
|
||||
"README.md": "/usr/share/mc/README.md"
|
||||
rpm:
|
||||
file_name_template: "{{ .Binary }}-release/rpms/{{ .ProjectName }}-{{ .Version }}.{{ .Arch }}"
|
||||
replacements:
|
||||
amd64: x86_64
|
||||
arm64: aarch64
|
||||
arm: armv7
|
||||
files:
|
||||
"NOTICE": "/usr/share/mc/NOTICE"
|
||||
"CREDITS": "/usr/share/mc/CREDITS"
|
||||
"LICENSE": "/usr/share/mc/LICENSE"
|
||||
"README.md": "/usr/share/mc/README.md"
|
||||
|
||||
checksum:
|
||||
algorithm: sha256
|
||||
|
||||
signs:
|
||||
-
|
||||
signature: "${artifact}.asc"
|
||||
cmd: "sh"
|
||||
args:
|
||||
- '-c'
|
||||
- 'gpg --quiet --detach-sign -a ${artifact}'
|
||||
artifacts: all
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^Update yaml files'
|
||||
|
||||
dockers:
|
||||
-
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: Dockerfile.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}
|
||||
- minio/mc:latest
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: ppc64le
|
||||
dockerfile: Dockerfile.ppc64le.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-ppc64le
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: s390x
|
||||
dockerfile: Dockerfile.s390x.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-s390x
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
goarm: ''
|
||||
dockerfile: Dockerfile.arm64.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-arm64
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: arm
|
||||
goarm: '7'
|
||||
dockerfile: Dockerfile.arm.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-arm
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.13-alpine
|
||||
FROM golang:1.13-alpine as build
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
@@ -11,12 +11,12 @@ RUN \
|
||||
git clone https://github.com/minio/mc && cd mc && \
|
||||
go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)"
|
||||
|
||||
FROM alpine:3.10
|
||||
FROM alpine:3.12
|
||||
|
||||
COPY --from=0 /go/bin/mc /usr/bin/mc
|
||||
COPY --from=build /go/bin/mc /usr/bin/mc
|
||||
|
||||
RUN \
|
||||
apk add --no-cache ca-certificates && \
|
||||
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
|
||||
apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
||||
curl -s -q -O https://raw.githubusercontent.com/minio/minio/master/CREDITS
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM multiarch/qemu-user-static:x86_64-arm as qemu
|
||||
FROM arm32v7/alpine:3.12
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
|
||||
COPY mc /usr/bin/mc
|
||||
|
||||
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
||||
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM multiarch/qemu-user-static:x86_64-arm as qemu
|
||||
FROM arm64v8/alpine:3.12
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
|
||||
COPY mc /usr/bin/mc
|
||||
|
||||
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
||||
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
+3
-5
@@ -1,10 +1,8 @@
|
||||
FROM alpine:3.10
|
||||
FROM alpine:3.12
|
||||
|
||||
COPY mc /usr/bin/
|
||||
COPY CREDITS /
|
||||
|
||||
RUN \
|
||||
apk add --no-cache ca-certificates && \
|
||||
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf \
|
||||
chmod +x /usr/bin/mc
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM multiarch/qemu-user-static:x86_64-arm as qemu
|
||||
FROM ppc64le/alpine:3.12
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
|
||||
COPY mc /usr/bin/mc
|
||||
|
||||
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
||||
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
+5
-6
@@ -1,11 +1,10 @@
|
||||
FROM alpine:3.10
|
||||
FROM alpine:3.12
|
||||
|
||||
MAINTAINER MinIO Inc <dev@min.io>
|
||||
|
||||
RUN \
|
||||
apk add --no-cache ca-certificates && \
|
||||
apk add --no-cache --virtual .build-deps curl && \
|
||||
curl https://dl.min.io/client/mc/release/linux-amd64/mc > /usr/bin/mc && \
|
||||
chmod +x /usr/bin/mc && apk del .build-deps
|
||||
COPY mc /usr/bin/mc
|
||||
|
||||
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
||||
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM multiarch/qemu-user-static:x86_64-arm as qemu
|
||||
FROM s390x/alpine:3.12
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
|
||||
COPY mc /usr/bin/mc
|
||||
|
||||
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
|
||||
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
@@ -1,4 +1,4 @@
|
||||
MinIO Client (C) 2014, 2015 MinIO, Inc.
|
||||
MinIO Client (C) 2014-2020 MinIO, Inc.
|
||||
|
||||
This product includes software developed at MinIO, Inc.
|
||||
(https://min.io/).
|
||||
|
||||
@@ -8,7 +8,7 @@ function _init() {
|
||||
export CGO_ENABLED=0
|
||||
|
||||
## List of architectures and OS to test coss compilation.
|
||||
SUPPORTED_OSARCH="linux/ppc64le linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 linux/arm linux/386"
|
||||
SUPPORTED_OSARCH="linux/ppc64le linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 linux/arm linux/386 windows/amd64"
|
||||
}
|
||||
|
||||
function _build() {
|
||||
|
||||
@@ -77,7 +77,7 @@ var adminBucketQuotaCmd = cli.Command{
|
||||
Name: "quota",
|
||||
Usage: "Manage bucket quota",
|
||||
Action: mainAdminBucketQuota,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(adminQuotaFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminBucketCmd = cli.Command{
|
||||
Name: "bucket",
|
||||
Usage: "manage buckets defined in the MinIO server",
|
||||
Action: mainAdminBucket,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminBucketQuotaCmd,
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
var adminConfigExportCmd = cli.Command{
|
||||
Name: "export",
|
||||
Usage: "export all config keys to STDOUT",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigExport,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
var adminConfigGetCmd = cli.Command{
|
||||
Name: "get",
|
||||
Usage: "interactively retrieve a config key parameters",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigGet,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -43,7 +43,7 @@ var historyListFlags = []cli.Flag{
|
||||
var adminConfigHistoryCmd = cli.Command{
|
||||
Name: "history",
|
||||
Usage: "show all historic configuration changes",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigHistory,
|
||||
Flags: append(append([]cli.Flag{}, globalFlags...), historyListFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
var adminConfigImportCmd = cli.Command{
|
||||
Name: "import",
|
||||
Usage: "import multiple config keys from STDIN",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigImport,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -37,7 +37,7 @@ var adminConfigEnvFlags = []cli.Flag{
|
||||
var adminConfigResetCmd = cli.Command{
|
||||
Name: "reset",
|
||||
Usage: "interactively reset a config key parameters",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigReset,
|
||||
Flags: append(adminConfigEnvFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
var adminConfigRestoreCmd = cli.Command{
|
||||
Name: "restore",
|
||||
Usage: "rollback back changes to a specific config history",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigRestore,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
var adminConfigSetCmd = cli.Command{
|
||||
Name: "set",
|
||||
Usage: "interactively set a config key parameters",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminConfigSet,
|
||||
Flags: append(adminConfigEnvFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminConfigCmd = cli.Command{
|
||||
Name: "config",
|
||||
Usage: "manage MinIO server configuration",
|
||||
Action: mainAdminConfig,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminConfigGetCmd,
|
||||
|
||||
@@ -49,7 +49,7 @@ var adminConsoleCmd = cli.Command{
|
||||
Name: "console",
|
||||
Usage: "show console logs for MinIO server",
|
||||
Action: mainAdminConsole,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(adminConsoleFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -32,7 +32,7 @@ var adminGroupAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add users to a new or existing group",
|
||||
Action: mainAdminGroupAdd,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -24,7 +24,7 @@ var adminGroupDisableCmd = cli.Command{
|
||||
Name: "disable",
|
||||
Usage: "Disable a group",
|
||||
Action: mainAdminGroupEnableDisable,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -30,7 +30,7 @@ var adminGroupEnableCmd = cli.Command{
|
||||
Name: "enable",
|
||||
Usage: "Enable a group",
|
||||
Action: mainAdminGroupEnableDisable,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminGroupInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "display group info",
|
||||
Action: mainAdminGroupInfo,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminGroupListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "display list of groups",
|
||||
Action: mainAdminGroupList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -28,7 +28,7 @@ var adminGroupRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove group or members from a group",
|
||||
Action: mainAdminGroupRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminGroupCmd = cli.Command{
|
||||
Name: "group",
|
||||
Usage: "manage groups",
|
||||
Action: mainAdminGroup,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminGroupAddCmd,
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ var adminHealCmd = cli.Command{
|
||||
Name: "heal",
|
||||
Usage: "heal disks, buckets and objects on MinIO server",
|
||||
Action: mainAdminHeal,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(adminHealFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ var adminInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "display MinIO server information",
|
||||
Action: mainAdminInfo,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -28,7 +28,7 @@ var adminKMSKeyStatusCmd = cli.Command{
|
||||
Name: "status",
|
||||
Usage: "request status information for a KMS master key",
|
||||
Action: mainAdminKMSKeyStatus,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminKMSKeyCmd = cli.Command{
|
||||
Name: "key",
|
||||
Usage: "Manage KMS master keys: Request key status information",
|
||||
Action: mainAdminKMSKey,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminKMSKeyStatusCmd,
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminKMSCmd = cli.Command{
|
||||
Name: "kms",
|
||||
Usage: "perform KMS management operations",
|
||||
Action: mainAdminKMS,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminKMSKeyCmd,
|
||||
|
||||
@@ -34,7 +34,6 @@ var adminCmd = cli.Command{
|
||||
Usage: "manage MinIO servers",
|
||||
Action: mainAdmin,
|
||||
HideHelpCommand: true,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(adminFlags, globalFlags...),
|
||||
Subcommands: []cli.Command{
|
||||
adminServiceCmd,
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ var adminOBDCmd = cli.Command{
|
||||
Name: "obd",
|
||||
Usage: "run on-board diagnostics",
|
||||
Action: mainAdminOBD,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(adminOBDFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -33,7 +33,7 @@ var adminPolicyAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add new policy",
|
||||
Action: mainAdminPolicyAdd,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -29,7 +29,7 @@ var adminPolicyInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "show info on a policy",
|
||||
Action: mainAdminPolicyInfo,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminPolicyListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list all policies",
|
||||
Action: mainAdminPolicyList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminPolicyRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove policy",
|
||||
Action: mainAdminPolicyRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -30,7 +30,7 @@ var adminPolicySetCmd = cli.Command{
|
||||
Name: "set",
|
||||
Usage: "set IAM policy on a user or group",
|
||||
Action: mainAdminPolicySet,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminPolicyCmd = cli.Command{
|
||||
Name: "policy",
|
||||
Usage: "manage policies defined in the MinIO server",
|
||||
Action: mainAdminPolicy,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminPolicyAddCmd,
|
||||
|
||||
@@ -38,7 +38,7 @@ var adminProfileStartCmd = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "start recording profile data",
|
||||
Action: mainAdminProfileStart,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(adminProfileStartFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -31,7 +31,7 @@ var adminProfileStopCmd = cli.Command{
|
||||
Name: "stop",
|
||||
Usage: "stop and download profile data",
|
||||
Action: mainAdminProfileStop,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -24,7 +24,6 @@ var adminProfileCmd = cli.Command{
|
||||
Name: "profile",
|
||||
Usage: "generate profile data for debugging purposes",
|
||||
Action: mainAdminProfile,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminProfileStartCmd,
|
||||
|
||||
@@ -40,7 +40,7 @@ var adminPrometheusGenerateCmd = cli.Command{
|
||||
Name: "generate",
|
||||
Usage: "generates prometheus config",
|
||||
Action: mainAdminPrometheusGenerate,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminPrometheusCmd = cli.Command{
|
||||
Name: "prometheus",
|
||||
Usage: "manages prometheus config",
|
||||
Action: mainAdminPrometheus,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
Subcommands: []cli.Command{
|
||||
|
||||
@@ -30,7 +30,7 @@ var adminServiceRestartCmd = cli.Command{
|
||||
Name: "restart",
|
||||
Usage: "restart all MinIO servers",
|
||||
Action: mainAdminServiceRestart,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -28,7 +28,7 @@ var adminServiceStopCmd = cli.Command{
|
||||
Name: "stop",
|
||||
Usage: "stop MinIO server",
|
||||
Action: mainAdminServiceStop,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminServiceCmd = cli.Command{
|
||||
Name: "service",
|
||||
Usage: "restart and stop all MinIO servers",
|
||||
Action: mainAdminService,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
Subcommands: []cli.Command{
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
var adminTopLocksCmd = cli.Command{
|
||||
Name: "locks",
|
||||
Usage: "Get a list of the 10 oldest locks on a MinIO cluster.",
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Action: mainAdminTopLocks,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminTopCmd = cli.Command{
|
||||
Name: "top",
|
||||
Usage: "provide top like statistics for MinIO",
|
||||
Action: mainAdminTop,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminTopLocksCmd,
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ var adminTraceCmd = cli.Command{
|
||||
Name: "trace",
|
||||
Usage: "show http trace for MinIO server",
|
||||
Action: mainAdminTrace,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(adminTraceFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ var adminServerUpdateCmd = cli.Command{
|
||||
Name: "update",
|
||||
Usage: "update all MinIO servers",
|
||||
Action: mainAdminServerUpdate,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -34,7 +34,7 @@ var adminUserAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add a new user",
|
||||
Action: mainAdminUserAdd,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -28,7 +28,7 @@ var adminUserDisableCmd = cli.Command{
|
||||
Name: "disable",
|
||||
Usage: "disable user",
|
||||
Action: mainAdminUserDisable,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -28,7 +28,7 @@ var adminUserEnableCmd = cli.Command{
|
||||
Name: "enable",
|
||||
Usage: "enable user",
|
||||
Action: mainAdminUserEnable,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminUserInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "display info of a user",
|
||||
Action: mainAdminUserInfo,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminUserListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list all users",
|
||||
Action: mainAdminUserList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,7 @@ var adminUserRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove user",
|
||||
Action: mainAdminUserRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,7 +22,6 @@ var adminUserCmd = cli.Command{
|
||||
Name: "user",
|
||||
Usage: "manage users",
|
||||
Action: mainAdminUser,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminUserAddCmd,
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ var catCmd = cli.Command{
|
||||
Name: "cat",
|
||||
Usage: "display object contents",
|
||||
Action: mainCat,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(append(catFlags, ioFlags...), globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mattn/go-ieproxy"
|
||||
"github.com/minio/mc/pkg/httptracer"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v6/pkg/credentials"
|
||||
@@ -90,7 +91,7 @@ func NewAdminFactory() func(config *Config) (*madmin.AdminClient, *probe.Error)
|
||||
}
|
||||
|
||||
var transport http.RoundTripper = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Proxy: ieproxy.GetProxyFunc(),
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 10 * time.Second,
|
||||
KeepAlive: 15 * time.Second,
|
||||
|
||||
+65
-32
@@ -223,29 +223,51 @@ func (f *fsClient) Watch(ctx context.Context, options WatchOptions) (*WatchObjec
|
||||
}
|
||||
|
||||
func preserveAttributes(fd *os.File, attr map[string]string) *probe.Error {
|
||||
mode, e := strconv.ParseUint(attr["mode"], 10, 32)
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
if val, ok := attr["mode"]; ok {
|
||||
mode, e := strconv.ParseUint(val, 0, 32)
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
|
||||
// Attempt to change the file mode.
|
||||
if e := fd.Chmod(os.FileMode(mode)); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to change the file mode.
|
||||
if e := fd.Chmod(os.FileMode(mode)); e != nil {
|
||||
return probe.NewError(e)
|
||||
var uid, gid int
|
||||
var gidExists, uidExists bool
|
||||
var e error
|
||||
if val, ok := attr["uid"]; ok {
|
||||
uid, e = strconv.Atoi(val)
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
uidExists = true
|
||||
}
|
||||
|
||||
uid, e := strconv.Atoi(attr["uid"])
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
|
||||
gid, e := strconv.Atoi(attr["gid"])
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
if val, ok := attr["gid"]; ok {
|
||||
gid, e = strconv.Atoi(val)
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
gidExists = true
|
||||
}
|
||||
|
||||
// Attempt to change the owner.
|
||||
if e := fd.Chown(uid, gid); e != nil {
|
||||
return probe.NewError(e)
|
||||
if gidExists && uidExists {
|
||||
if e := fd.Chown(uid, gid); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
} else if uidExists {
|
||||
if e := fd.Chown(uid, -1); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
if e := fd.Chown(-1, gid); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -253,7 +275,7 @@ func preserveAttributes(fd *os.File, attr map[string]string) *probe.Error {
|
||||
|
||||
/// Object operations.
|
||||
|
||||
func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metadata map[string][]string, progress io.Reader) (int64, *probe.Error) {
|
||||
func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metadata map[string][]string, progress io.Reader, preserve bool) (int64, *probe.Error) {
|
||||
// ContentType is not handled on purpose.
|
||||
// For filesystem this is a redundant information.
|
||||
|
||||
@@ -289,7 +311,7 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metada
|
||||
}
|
||||
|
||||
attr := make(map[string]string)
|
||||
if len(metadata[metaDataKey]) != 0 {
|
||||
if len(metadata[metaDataKey]) != 0 && preserve {
|
||||
attr, e = parseAttribute(metadata[metaDataKey][0])
|
||||
if e != nil {
|
||||
tmpFile.Close()
|
||||
@@ -347,20 +369,31 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metada
|
||||
return totalWritten, err.Trace(objectPartPath, objectPath)
|
||||
}
|
||||
|
||||
if len(attr) != 0 {
|
||||
atime, e := strconv.ParseInt(attr["atime"], 10, 64)
|
||||
if e != nil {
|
||||
return totalWritten, probe.NewError(e)
|
||||
if len(attr) != 0 && preserve {
|
||||
var atime, mtime int64
|
||||
var e error
|
||||
var atimeChanged, mtimeChanged bool
|
||||
if val, ok := attr["atime"]; ok {
|
||||
atime, e = strconv.ParseInt(val, 10, 64)
|
||||
if e != nil {
|
||||
return totalWritten, probe.NewError(e)
|
||||
}
|
||||
atimeChanged = true
|
||||
}
|
||||
|
||||
mtime, e := strconv.ParseInt(attr["mtime"], 10, 64)
|
||||
if e != nil {
|
||||
return totalWritten, probe.NewError(e)
|
||||
if val, ok := attr["mtime"]; ok {
|
||||
mtime, e = strconv.ParseInt(val, 10, 64)
|
||||
if e != nil {
|
||||
return totalWritten, probe.NewError(e)
|
||||
}
|
||||
mtimeChanged = true
|
||||
}
|
||||
|
||||
// Attempt to change the access and modify time
|
||||
if e := os.Chtimes(objectPath, time.Unix(atime, 0), time.Unix(mtime, 0)); e != nil {
|
||||
return totalWritten, probe.NewError(e)
|
||||
if atimeChanged && mtimeChanged {
|
||||
if e := os.Chtimes(objectPath, time.Unix(atime, 0), time.Unix(mtime, 0)); e != nil {
|
||||
return totalWritten, probe.NewError(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,13 +401,13 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metada
|
||||
}
|
||||
|
||||
// Put - create a new file with metadata.
|
||||
func (f *fsClient) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (int64, *probe.Error) {
|
||||
func (f *fsClient) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, preserve bool) (int64, *probe.Error) {
|
||||
if metadata[metaDataKey] != "" {
|
||||
meta := make(map[string][]string)
|
||||
meta[metaDataKey] = append(meta[metaDataKey], metadata[metaDataKey])
|
||||
return f.put(ctx, reader, size, meta, progress)
|
||||
return f.put(ctx, reader, size, meta, progress, preserve)
|
||||
}
|
||||
return f.put(ctx, reader, size, nil, progress)
|
||||
return f.put(ctx, reader, size, nil, progress, preserve)
|
||||
}
|
||||
|
||||
// ShareDownload - share download not implemented for filesystem.
|
||||
@@ -394,7 +427,7 @@ func (f *fsClient) ShareUpload(startsWith bool, expires time.Duration, contentTy
|
||||
}
|
||||
|
||||
// Copy - copy data from source to destination
|
||||
func (f *fsClient) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart bool) *probe.Error {
|
||||
func (f *fsClient) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart, preserve bool) *probe.Error {
|
||||
rc, e := os.Open(source)
|
||||
if e != nil {
|
||||
err := f.toClientError(e, source)
|
||||
@@ -403,7 +436,7 @@ func (f *fsClient) Copy(ctx context.Context, source string, size int64, progress
|
||||
defer rc.Close()
|
||||
|
||||
destination := f.PathURL.Path
|
||||
if _, err := f.put(ctx, rc, size, map[string][]string{}, progress); err != nil {
|
||||
if _, err := f.put(ctx, rc, size, map[string][]string{}, progress, preserve); err != nil {
|
||||
return err.Trace(destination, source)
|
||||
}
|
||||
return nil
|
||||
|
||||
+10
-10
@@ -45,7 +45,7 @@ func (s *TestSuite) TestList(c *C) {
|
||||
var n int64
|
||||
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *TestSuite) TestList(c *C) {
|
||||
reader = bytes.NewReader([]byte(data))
|
||||
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -84,7 +84,7 @@ func (s *TestSuite) TestList(c *C) {
|
||||
reader = bytes.NewReader([]byte(data))
|
||||
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -144,7 +144,7 @@ func (s *TestSuite) TestList(c *C) {
|
||||
reader = bytes.NewReader([]byte(data))
|
||||
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -251,7 +251,7 @@ func (s *TestSuite) TestPut(c *C) {
|
||||
var n int64
|
||||
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func (s *TestSuite) TestGet(c *C) {
|
||||
reader = bytes.NewReader([]byte(data))
|
||||
n, err := fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s *TestSuite) TestGetRange(c *C) {
|
||||
reader = bytes.NewReader([]byte(data))
|
||||
n, err := fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -330,7 +330,7 @@ func (s *TestSuite) TestStatObject(c *C) {
|
||||
reader := bytes.NewReader([]byte(data))
|
||||
n, err := fsClient.Put(context.Background(), reader, int64(dataLen), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -355,10 +355,10 @@ func (s *TestSuite) TestCopy(c *C) {
|
||||
reader := bytes.NewReader([]byte(data))
|
||||
n, err := fsClientSource.Put(context.Background(), reader, int64(len(data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
err = fsClientTarget.Copy(context.Background(), sourcePath, int64(len(data)), nil, nil, nil, nil, false)
|
||||
err = fsClientTarget.Copy(context.Background(), sourcePath, int64(len(data)), nil, nil, nil, nil, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
+5
-4
@@ -37,6 +37,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mattn/go-ieproxy"
|
||||
"github.com/minio/mc/cmd/ilm"
|
||||
"github.com/minio/mc/pkg/httptracer"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
@@ -149,7 +150,7 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
}
|
||||
|
||||
tr := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Proxy: ieproxy.GetProxyFunc(),
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 10 * time.Second,
|
||||
KeepAlive: 15 * time.Second,
|
||||
@@ -839,7 +840,7 @@ func (c *S3Client) Get(ctx context.Context, sse encrypt.ServerSide) (io.ReadClos
|
||||
// Copy - copy object, uses server side copy API. Also uses an abstracted API
|
||||
// such that large file sizes will be copied in multipart manner on server
|
||||
// side.
|
||||
func (c *S3Client) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart bool) *probe.Error {
|
||||
func (c *S3Client) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart, isPreserve bool) *probe.Error {
|
||||
dstBucket, dstObject := c.url2BucketAndObject()
|
||||
if dstBucket == "" {
|
||||
return probe.NewError(BucketNameEmpty{})
|
||||
@@ -912,7 +913,7 @@ func (c *S3Client) Copy(ctx context.Context, source string, size int64, progress
|
||||
}
|
||||
|
||||
// Put - upload an object with custom metadata.
|
||||
func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (int64, *probe.Error) {
|
||||
func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, isPreserve bool) (int64, *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if bucket == "" {
|
||||
return 0, probe.NewError(BucketNameEmpty{})
|
||||
@@ -1325,7 +1326,7 @@ func (c *S3Client) listObjectWrapper(ctx context.Context, bucket, object string,
|
||||
if isGoogle(c.targetURL.Host) {
|
||||
// Google Cloud S3 layer doesn't implement ListObjectsV2 implementation
|
||||
// https://github.com/minio/mc/issues/3073
|
||||
return c.api.ListObjectsV2WithContext(ctx, bucket, object, isRecursive, doneCh)
|
||||
return c.api.ListObjectsWithContext(ctx, bucket, object, isRecursive, doneCh)
|
||||
}
|
||||
if metadata {
|
||||
return c.api.ListObjectsV2WithMetadataWithContext(ctx, bucket, object, isRecursive, doneCh)
|
||||
|
||||
@@ -223,7 +223,7 @@ func (s *TestSuite) TestObjectOperations(c *C) {
|
||||
reader = bytes.NewReader(object.data)
|
||||
n, err := s3c.Put(context.Background(), reader, int64(len(object.data)), map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}, nil, nil, false, false)
|
||||
}, nil, nil, false, false, false)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(object.data)))
|
||||
|
||||
|
||||
+2
-2
@@ -62,14 +62,14 @@ type Client interface {
|
||||
SetAccess(ctx context.Context, access string, isJSON bool) *probe.Error
|
||||
|
||||
// I/O operations
|
||||
Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart bool) *probe.Error
|
||||
Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart, isPreserve bool) *probe.Error
|
||||
|
||||
// Runs select expression on object storage on specific files.
|
||||
Select(ctx context.Context, expression string, sse encrypt.ServerSide, opts SelectObjectOpts) (io.ReadCloser, *probe.Error)
|
||||
|
||||
// I/O operations with metadata.
|
||||
Get(ctx context.Context, sse encrypt.ServerSide) (reader io.ReadCloser, err *probe.Error)
|
||||
Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (n int64, err *probe.Error)
|
||||
Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, isPreserve bool) (n int64, err *probe.Error)
|
||||
|
||||
// Object Locking related API
|
||||
PutObjectRetention(ctx context.Context, mode minio.RetentionMode, retainUntilDate time.Time, bypassGovernance bool) *probe.Error
|
||||
|
||||
+35
-22
@@ -297,7 +297,7 @@ func putTargetRetention(ctx context.Context, alias string, urlStr string, metada
|
||||
}
|
||||
|
||||
// putTargetStream writes to URL from Reader.
|
||||
func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold string, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (int64, *probe.Error) {
|
||||
func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold string, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, preserve bool) (int64, *probe.Error) {
|
||||
targetClnt, err := newClientFromAlias(alias, urlStr)
|
||||
if err != nil {
|
||||
return 0, err.Trace(alias, urlStr)
|
||||
@@ -312,7 +312,7 @@ func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold
|
||||
if legalHold != "" {
|
||||
metadata[AmzObjectLockLegalHold] = legalHold
|
||||
}
|
||||
n, err := targetClnt.Put(ctx, reader, size, metadata, progress, sse, md5, disableMultipart)
|
||||
n, err := targetClnt.Put(ctx, reader, size, metadata, progress, sse, md5, disableMultipart, preserve)
|
||||
if err != nil {
|
||||
return n, err.Trace(alias, urlStr)
|
||||
}
|
||||
@@ -320,7 +320,7 @@ func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold
|
||||
}
|
||||
|
||||
// putTargetStreamWithURL writes to URL from reader. If length=-1, read until EOF.
|
||||
func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, sse encrypt.ServerSide, md5, disableMultipart bool, metadata map[string]string) (int64, *probe.Error) {
|
||||
func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, sse encrypt.ServerSide, md5, disableMultipart, preserve bool, metadata map[string]string) (int64, *probe.Error) {
|
||||
alias, urlStrFull, _, err := expandAlias(urlStr)
|
||||
if err != nil {
|
||||
return 0, err.Trace(alias, urlStr)
|
||||
@@ -330,7 +330,7 @@ func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, sse enc
|
||||
metadata = map[string]string{}
|
||||
}
|
||||
metadata["Content-Type"] = contentType
|
||||
return putTargetStream(context.Background(), alias, urlStrFull, "", "", "", reader, size, metadata, nil, sse, md5, disableMultipart)
|
||||
return putTargetStream(context.Background(), alias, urlStrFull, "", "", "", reader, size, metadata, nil, sse, md5, disableMultipart, preserve)
|
||||
}
|
||||
|
||||
// copySourceToTargetURL copies to targetURL from source.
|
||||
@@ -344,7 +344,7 @@ func copySourceToTargetURL(ctx context.Context, alias, urlStr, source, mode, unt
|
||||
metadata[AmzObjectLockMode] = mode
|
||||
metadata[AmzObjectLockRetainUntilDate] = until
|
||||
metadata[AmzObjectLockLegalHold] = legalHold
|
||||
err = targetClnt.Copy(ctx, source, size, progress, srcSSE, tgtSSE, metadata, disableMultipart)
|
||||
err = targetClnt.Copy(ctx, source, size, progress, srcSSE, tgtSSE, metadata, disableMultipart, false)
|
||||
|
||||
if err != nil {
|
||||
return err.Trace(alias, urlStr)
|
||||
@@ -381,11 +381,11 @@ func getAllMetadata(ctx context.Context, sourceAlias, sourceURLStr string, srcSS
|
||||
}
|
||||
|
||||
for k, v := range st.Metadata {
|
||||
metadata[k] = v
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
for k, v := range urls.TargetContent.UserMetadata {
|
||||
metadata[k] = v
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
return filterMetadata(metadata), nil
|
||||
@@ -455,44 +455,56 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
|
||||
if sourceAlias == targetAlias {
|
||||
// If no metadata populated already by the caller
|
||||
// just do a Stat() to obtain the metadata.
|
||||
if len(metadata) == 0 {
|
||||
if len(metadata) == 0 && preserve {
|
||||
metadata, err = getAllMetadata(ctx, sourceAlias, sourceURL.String(), srcSSE, urls, preserve)
|
||||
if err != nil {
|
||||
return urls.WithError(err.Trace(sourceURL.String()))
|
||||
}
|
||||
}
|
||||
|
||||
// Get metadata from target content as well
|
||||
for k, v := range urls.TargetContent.Metadata {
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
// Get userMetadata from target content as well
|
||||
for k, v := range urls.TargetContent.UserMetadata {
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
sourcePath := filepath.ToSlash(sourceURL.Path)
|
||||
if urls.SourceContent.RetentionEnabled {
|
||||
err = putTargetRetention(ctx, targetAlias, targetURL.String(), metadata)
|
||||
return urls.WithError(err.Trace(sourceURL.String()))
|
||||
}
|
||||
|
||||
// Get metadata from target content as well
|
||||
for k, v := range urls.TargetContent.Metadata {
|
||||
metadata[k] = v
|
||||
}
|
||||
// Get userMetadata from target content as well
|
||||
for k, v := range urls.TargetContent.UserMetadata {
|
||||
metadata[k] = v
|
||||
}
|
||||
|
||||
err = copySourceToTargetURL(ctx, targetAlias, targetURL.String(), sourcePath, mode, until,
|
||||
legalHold, length, progress, srcSSE, tgtSSE, filterMetadata(metadata), urls.DisableMultipart)
|
||||
} else {
|
||||
if urls.SourceContent.RetentionEnabled {
|
||||
// If no metadata populated already by the caller
|
||||
// just do a Stat() to obtain the metadata.
|
||||
if len(metadata) == 0 {
|
||||
if len(metadata) == 0 && preserve {
|
||||
metadata, err = getAllMetadata(ctx, sourceAlias, sourceURL.String(), srcSSE, urls, preserve)
|
||||
if err != nil {
|
||||
return urls.WithError(err.Trace(sourceURL.String()))
|
||||
}
|
||||
}
|
||||
|
||||
// Get metadata from target content as well
|
||||
for k, v := range urls.TargetContent.Metadata {
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
// Get userMetadata from target content as well
|
||||
for k, v := range urls.TargetContent.UserMetadata {
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
err = putTargetRetention(ctx, targetAlias, targetURL.String(), metadata)
|
||||
return urls.WithError(err.Trace(sourceURL.String()))
|
||||
}
|
||||
|
||||
var reader io.ReadCloser
|
||||
// Proceed with regular stream copy.
|
||||
reader, metadata, err = getSourceStream(ctx, sourceAlias, sourceURL.String(), true, srcSSE, preserve)
|
||||
@@ -503,22 +515,23 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
|
||||
|
||||
// Get metadata from target content as well
|
||||
for k, v := range urls.TargetContent.Metadata {
|
||||
metadata[k] = v
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
// Get userMetadata from target content as well
|
||||
for k, v := range urls.TargetContent.UserMetadata {
|
||||
metadata[k] = v
|
||||
metadata[http.CanonicalHeaderKey(k)] = v
|
||||
}
|
||||
|
||||
if isReadAt(reader) {
|
||||
_, err = putTargetStream(ctx, targetAlias, targetURL.String(), mode, until,
|
||||
legalHold, reader, length, filterMetadata(metadata),
|
||||
progress, tgtSSE, urls.MD5, urls.DisableMultipart)
|
||||
progress, tgtSSE, urls.MD5, urls.DisableMultipart, preserve)
|
||||
} else {
|
||||
_, err = putTargetStream(ctx, targetAlias, targetURL.String(), mode, until,
|
||||
legalHold, io.LimitReader(reader, length),
|
||||
length, filterMetadata(metadata), progress, tgtSSE, urls.MD5,
|
||||
urls.DisableMultipart)
|
||||
urls.DisableMultipart, preserve)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -50,7 +50,7 @@ var configHostAddCmd = cli.Command{
|
||||
ShortName: "a",
|
||||
Usage: "add a new host to configuration file",
|
||||
Action: mainConfigHostAdd,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(hostAddFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -30,7 +30,7 @@ var configHostListCmd = cli.Command{
|
||||
ShortName: "ls",
|
||||
Usage: "list hosts in configuration file",
|
||||
Action: mainConfigHostList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -27,7 +27,7 @@ var configHostRemoveCmd = cli.Command{
|
||||
ShortName: "rm",
|
||||
Usage: "remove a host from configuration file",
|
||||
Action: mainConfigHostRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
|
||||
@@ -27,7 +27,6 @@ var configHostCmd = cli.Command{
|
||||
Name: "host",
|
||||
Usage: "add, remove and list hosts in configuration file",
|
||||
Action: mainConfigHost,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
configHostAddCmd,
|
||||
|
||||
@@ -37,7 +37,6 @@ var configCmd = cli.Command{
|
||||
Name: "config",
|
||||
Usage: "configure MinIO client",
|
||||
Action: mainConfig,
|
||||
Before: setGlobalsFromContext,
|
||||
HideHelpCommand: true,
|
||||
Flags: append(configFlags, globalFlags...),
|
||||
Subcommands: []cli.Command{
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ var cpCmd = cli.Command{
|
||||
Name: "cp",
|
||||
Usage: "copy objects",
|
||||
Action: mainCopy,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(append(cpFlags, ioFlags...), globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -18,7 +18,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -193,18 +192,6 @@ func makeCopyContentTypeC(sourceAlias string, sourceURL ClientURL, sourceContent
|
||||
newSourceSuffix := filepath.ToSlash(newSourceURL.Path)
|
||||
if pathSeparatorIndex > 1 {
|
||||
sourcePrefix := filepath.ToSlash(sourceURL.Path[:pathSeparatorIndex])
|
||||
// do not preserve unix cp behavior when copying a filesytem dir to
|
||||
// objectstore.
|
||||
if sourceAlias == "" && targetAlias != "" {
|
||||
// Check if sourceURL.Path is a directory or not
|
||||
fileInfo, err := os.Stat(sourceURL.Path)
|
||||
if err != nil {
|
||||
return URLs{Error: probe.NewError(err)}
|
||||
}
|
||||
if fileInfo.IsDir() {
|
||||
sourcePrefix = filepath.ToSlash(sourceURL.Path)
|
||||
}
|
||||
}
|
||||
newSourceSuffix = strings.TrimPrefix(newSourceSuffix, sourcePrefix)
|
||||
}
|
||||
newTargetURL := urlJoinPath(targetURL, newSourceSuffix)
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ var diffCmd = cli.Command{
|
||||
Name: "diff",
|
||||
Usage: "list differences in object name, size, and date between two buckets",
|
||||
Action: mainDiff,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(diffFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
@@ -149,7 +149,7 @@ func checkDiffSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[stri
|
||||
}
|
||||
|
||||
// doDiffMain runs the diff.
|
||||
func doDiffMain(firstURL, secondURL string) error {
|
||||
func doDiffMain(ctx context.Context, firstURL, secondURL string) error {
|
||||
// Source and targets are always directories
|
||||
sourceSeparator := string(newClientURL(firstURL).Separator)
|
||||
if !strings.HasSuffix(firstURL, sourceSeparator) {
|
||||
@@ -177,7 +177,7 @@ func doDiffMain(firstURL, secondURL string) error {
|
||||
}
|
||||
|
||||
// Diff first and second urls.
|
||||
for diffMsg := range objectDifference(firstClient, secondClient, firstURL, secondURL, false) {
|
||||
for diffMsg := range objectDifference(ctx, firstClient, secondClient, firstURL, secondURL, true) {
|
||||
if diffMsg.Error != nil {
|
||||
errorIf(diffMsg.Error, "Unable to calculate objects difference.")
|
||||
// Ignore error and proceed to next object.
|
||||
@@ -214,5 +214,5 @@ func mainDiff(cliCtx *cli.Context) error {
|
||||
firstURL := URLs.Get(0)
|
||||
secondURL := URLs.Get(1)
|
||||
|
||||
return doDiffMain(firstURL, secondURL)
|
||||
return doDiffMain(ctx, firstURL, secondURL)
|
||||
}
|
||||
|
||||
+59
-29
@@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
@@ -63,18 +64,20 @@ func (d differType) String() string {
|
||||
|
||||
const activeActiveSourceModTimeKey = "X-Amz-Meta-Mm-Source-Mtime"
|
||||
|
||||
func oldestNonNullTime(t1, t2 time.Time) time.Time {
|
||||
if t1.IsZero() {
|
||||
return t2
|
||||
func getSourceModTimeKey(metadata map[string]string) string {
|
||||
if metadata[activeActiveSourceModTimeKey] != "" {
|
||||
return metadata[activeActiveSourceModTimeKey]
|
||||
}
|
||||
if t2.IsZero() {
|
||||
return t1
|
||||
if metadata[strings.ToLower(activeActiveSourceModTimeKey)] != "" {
|
||||
return metadata[strings.ToLower(activeActiveSourceModTimeKey)]
|
||||
}
|
||||
if t1.Before(t2) {
|
||||
return t1
|
||||
if metadata[strings.ToLower("Mm-Source-Mtime")] != "" {
|
||||
return metadata[strings.ToLower("Mm-Source-Mtime")]
|
||||
}
|
||||
|
||||
return t2
|
||||
if metadata["Mm-Source-Mtime"] != "" {
|
||||
return metadata["Mm-Source-Mtime"]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// activeActiveModTimeUpdated tries to calculate if the object copy in the target
|
||||
@@ -91,18 +94,39 @@ func activeActiveModTimeUpdated(src, dst *ClientContent) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
_, ok1 := src.UserMetadata[activeActiveSourceModTimeKey]
|
||||
_, ok2 := dst.UserMetadata[activeActiveSourceModTimeKey]
|
||||
if !ok1 && !ok2 {
|
||||
// No multimaster context found, consider src & dst as similar
|
||||
srcModTime := getSourceModTimeKey(src.UserMetadata)
|
||||
dstModTime := getSourceModTimeKey(dst.UserMetadata)
|
||||
if srcModTime == "" && dstModTime == "" {
|
||||
// No active-active mirror context found, consider src & dst as similar
|
||||
return false
|
||||
}
|
||||
|
||||
srcOriginLastModified, _ := time.Parse(time.RFC3339Nano, src.UserMetadata[activeActiveSourceModTimeKey])
|
||||
dstOriginLastModified, _ := time.Parse(time.RFC3339Nano, dst.UserMetadata[activeActiveSourceModTimeKey])
|
||||
var srcOriginLastModified, dstOriginLastModified time.Time
|
||||
var err error
|
||||
if srcModTime != "" {
|
||||
srcOriginLastModified, err = time.Parse(time.RFC3339Nano, srcModTime)
|
||||
if err != nil {
|
||||
// failure to parse source modTime, modTime tampered ignore the file
|
||||
return false
|
||||
}
|
||||
}
|
||||
if dstModTime != "" {
|
||||
dstOriginLastModified, err = time.Parse(time.RFC3339Nano, dstModTime)
|
||||
if err != nil {
|
||||
// failure to parse source modTime, modTime tampered ignore the file
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
srcActualModTime := oldestNonNullTime(src.Time, srcOriginLastModified)
|
||||
dstActualModTime := oldestNonNullTime(dst.Time, dstOriginLastModified)
|
||||
srcActualModTime := src.Time
|
||||
if !srcOriginLastModified.IsZero() && srcOriginLastModified.After(src.Time) {
|
||||
srcActualModTime = srcOriginLastModified
|
||||
}
|
||||
|
||||
dstActualModTime := dst.Time
|
||||
if !dstOriginLastModified.IsZero() && dstOriginLastModified.After(dst.Time) {
|
||||
dstActualModTime = dstOriginLastModified
|
||||
}
|
||||
|
||||
return srcActualModTime.After(dstActualModTime)
|
||||
}
|
||||
@@ -112,6 +136,9 @@ func metadataEqual(m1, m2 map[string]string) bool {
|
||||
if k == activeActiveSourceModTimeKey {
|
||||
continue
|
||||
}
|
||||
if k == strings.ToLower(activeActiveSourceModTimeKey) {
|
||||
continue
|
||||
}
|
||||
if m2[k] != v {
|
||||
return false
|
||||
}
|
||||
@@ -120,6 +147,9 @@ func metadataEqual(m1, m2 map[string]string) bool {
|
||||
if k == activeActiveSourceModTimeKey {
|
||||
continue
|
||||
}
|
||||
if k == strings.ToLower(activeActiveSourceModTimeKey) {
|
||||
continue
|
||||
}
|
||||
if m1[k] != v {
|
||||
return false
|
||||
}
|
||||
@@ -127,19 +157,19 @@ func metadataEqual(m1, m2 map[string]string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func objectDifference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool) (diffCh chan diffMessage) {
|
||||
return difference(sourceClnt, targetClnt, sourceURL, targetURL, isMetadata, true, false, DirNone)
|
||||
func objectDifference(ctx context.Context, sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool) (diffCh chan diffMessage) {
|
||||
return difference(ctx, sourceClnt, targetClnt, sourceURL, targetURL, isMetadata, true, false, DirNone)
|
||||
}
|
||||
|
||||
func dirDifference(sourceClnt, targetClnt Client, sourceURL, targetURL string) (diffCh chan diffMessage) {
|
||||
return difference(sourceClnt, targetClnt, sourceURL, targetURL, false, false, true, DirFirst)
|
||||
func dirDifference(ctx context.Context, sourceClnt, targetClnt Client, sourceURL, targetURL string) (diffCh chan diffMessage) {
|
||||
return difference(ctx, sourceClnt, targetClnt, sourceURL, targetURL, false, false, true, DirFirst)
|
||||
}
|
||||
|
||||
func differenceInternal(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt, diffCh chan<- diffMessage) *probe.Error {
|
||||
func differenceInternal(ctx context.Context, sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt, diffCh chan<- diffMessage) *probe.Error {
|
||||
// Set default values for listing.
|
||||
isIncomplete := false // we will not compare any incomplete objects.
|
||||
srcCh := sourceClnt.List(globalContext, isRecursive, isIncomplete, isMetadata, dirOpt)
|
||||
tgtCh := targetClnt.List(globalContext, isRecursive, isIncomplete, isMetadata, dirOpt)
|
||||
srcCh := sourceClnt.List(ctx, isRecursive, isIncomplete, isMetadata, dirOpt)
|
||||
tgtCh := targetClnt.List(ctx, isRecursive, isIncomplete, isMetadata, dirOpt)
|
||||
|
||||
srcCtnt, srcOk := <-srcCh
|
||||
tgtCtnt, tgtOk := <-tgtCh
|
||||
@@ -296,17 +326,17 @@ func differenceInternal(sourceClnt, targetClnt Client, sourceURL, targetURL stri
|
||||
|
||||
// objectDifference function finds the difference between all objects
|
||||
// recursively in sorted order from source and target.
|
||||
func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt) (diffCh chan diffMessage) {
|
||||
func difference(ctx context.Context, sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt) (diffCh chan diffMessage) {
|
||||
diffCh = make(chan diffMessage, 10000)
|
||||
|
||||
go func() {
|
||||
defer close(diffCh)
|
||||
|
||||
doneCh := make(chan struct{}, 1)
|
||||
defer close(doneCh)
|
||||
retryCtx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
for range newRetryTimerContinous(time.Second, time.Second*30, minio.MaxJitter, doneCh) {
|
||||
err := differenceInternal(sourceClnt, targetClnt, sourceURL, targetURL,
|
||||
for range newRetryTimerContinous(retryCtx, time.Second, time.Second*30, minio.MaxJitter) {
|
||||
err := differenceInternal(retryCtx, sourceClnt, targetClnt, sourceURL, targetURL,
|
||||
isMetadata, isRecursive, returnSimilar, dirOpt, diffCh)
|
||||
if err != nil {
|
||||
// handle this specifically for filesystem related errors.
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ var duCmd = cli.Command{
|
||||
Name: "du",
|
||||
Usage: "summarize disk usage recursively",
|
||||
Action: mainDu,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(append(duFlags, ioFlags...), globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ var eventAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add a new bucket notification",
|
||||
Action: mainEventAdd,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(eventAddFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ var eventListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list bucket notifications",
|
||||
Action: mainEventList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(eventListFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -27,7 +27,6 @@ var eventCmd = cli.Command{
|
||||
Usage: "configure object notifications",
|
||||
HideHelpCommand: true,
|
||||
Action: mainEvent,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(eventFlags, globalFlags...),
|
||||
Subcommands: []cli.Command{
|
||||
eventAddCmd,
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ var eventRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove a bucket notification; '--force' removes all bucket notifications",
|
||||
Action: mainEventRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(eventRemoveFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ var findCmd = cli.Command{
|
||||
Name: "find",
|
||||
Usage: "search for objects",
|
||||
Action: mainFind,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(findFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ var headCmd = cli.Command{
|
||||
Name: "head",
|
||||
Usage: "display first 'n' lines of an object",
|
||||
Action: mainHead,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(append(headFlags, ioFlags...), globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ var ilmAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add a lifecycle configuration rule to existing (if any) rule(s) on a bucket",
|
||||
Action: mainILMAdd,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(ilmAddFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
@@ -53,7 +53,7 @@ EXAMPLES:
|
||||
|
||||
2. Add rule for testbucket on s3. Both expiry and transition are number of days.
|
||||
{{.Prompt}} {{.HelpName}} --id "Docs" --prefix "doc/" \
|
||||
--expiry-days "200" --transition-days "300 days" \
|
||||
--expiry-days "300" --transition-days "200" \
|
||||
--storage-class "GLACIER" s3/testbucket
|
||||
|
||||
3. Add rule for testbucket on s3. Only expiry is given as number of days and transition is not set.
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ var ilmExportCmd = cli.Command{
|
||||
Name: "export",
|
||||
Usage: "export lifecycle configuration in JSON format",
|
||||
Action: mainILMExport,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ var ilmImportCmd = cli.Command{
|
||||
Name: "import",
|
||||
Usage: "import lifecycle configuration in JSON format",
|
||||
Action: mainILMImport,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ var ilmListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "pretty print bucket lifecycle configuration",
|
||||
Action: mainILMList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(ilmListFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -26,7 +26,6 @@ var ilmCmd = cli.Command{
|
||||
Name: "ilm",
|
||||
Usage: "configure bucket lifecycle",
|
||||
Action: mainILM,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
Subcommands: []cli.Command{
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ var ilmRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove (if any) existing lifecycle configuration rule with the id",
|
||||
Action: mainILMRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(ilmRemoveFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
@@ -22,9 +22,9 @@ import (
|
||||
|
||||
const (
|
||||
// rule ID field column width in table output
|
||||
idColumnWidth int = 12
|
||||
idColumnWidth int = 16
|
||||
// rule prefix field column width in table output
|
||||
prefixColumnWidth int = 10
|
||||
prefixColumnWidth int = 16
|
||||
// StatusColumnWidth column width in table output
|
||||
statusColumnWidth int = 12
|
||||
// ExpiryColumnWidth column width in table output
|
||||
@@ -302,7 +302,10 @@ func checkAddTableCell(rowArr *[]string, rowCheck map[string]int, cellInfo table
|
||||
if colIdx, ok := rowCheck[cellInfo.labelKey]; ok {
|
||||
if len(cellInfo.label)%2 != 0 && len(cellInfo.label) < cellInfo.columnWidth {
|
||||
cellInfo.label += " "
|
||||
} else if len(cellInfo.label) > (cellInfo.columnWidth - 2) { // 2 dots to indicate text longer than column width
|
||||
cellInfo.label = cellInfo.label[:(cellInfo.columnWidth-6)] + ".."
|
||||
}
|
||||
|
||||
(*rowArr)[colIdx] = getAlignedText(cellInfo.label, cellInfo.align, cellInfo.columnWidth)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ var legalHoldCmd = cli.Command{
|
||||
Name: "legalhold",
|
||||
Usage: "set legal hold for object(s)",
|
||||
Action: mainLegalHold,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(lhFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ var lockCmd = cli.Command{
|
||||
Name: "lock",
|
||||
Usage: "set and get object lock configuration",
|
||||
Action: mainLock,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(lockFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ var lsCmd = cli.Command{
|
||||
Name: "ls",
|
||||
Usage: "list buckets and objects",
|
||||
Action: mainList,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(lsFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+20
-20
@@ -255,25 +255,6 @@ func installAutoCompletion() {
|
||||
}
|
||||
}
|
||||
|
||||
func registerBefore(ctx *cli.Context) error {
|
||||
// Set the config directory.
|
||||
setMcConfigDir(ctx.GlobalString("config-dir"))
|
||||
|
||||
// Migrate any old version of config / state files to newer format.
|
||||
migrate()
|
||||
|
||||
// Set global flags.
|
||||
setGlobalsFromContext(ctx)
|
||||
|
||||
// Initialize default config files.
|
||||
initMC()
|
||||
|
||||
// Check if config can be read.
|
||||
checkConfig()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// findClosestCommands to match a given string with commands trie tree.
|
||||
func findClosestCommands(command string) []string {
|
||||
var closestCommands []string
|
||||
@@ -313,6 +294,26 @@ func checkUpdate(ctx *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// All the routines that need to be done before running any mc command
|
||||
func initBeforeRunningCmd(ctx *cli.Context) error {
|
||||
// Set global variables from the context
|
||||
setGlobalsFromContext(ctx)
|
||||
|
||||
// Set the config directory.
|
||||
setMcConfigDir(ctx.GlobalString("config-dir"))
|
||||
|
||||
// Migrate any old version of config / state files to newer format.
|
||||
migrate()
|
||||
|
||||
// Initialize default config files.
|
||||
initMC()
|
||||
|
||||
// Check if config can be read.
|
||||
checkConfig()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var appCmds = []cli.Command{
|
||||
lsCmd,
|
||||
mbCmd,
|
||||
@@ -372,7 +373,6 @@ func registerApp(name string) *cli.App {
|
||||
return exitStatus(globalErrorExitStatus)
|
||||
}
|
||||
|
||||
app.Before = registerBefore
|
||||
app.ExtraInfo = func() map[string]string {
|
||||
if globalDebug {
|
||||
return getSystemData()
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/minio/cli"
|
||||
)
|
||||
|
||||
// This function checks that only leaf commands have Before
|
||||
// function configured to avoid calling it multiple times.
|
||||
func TestBeforeCommand(t *testing.T) {
|
||||
var checkCmd func(string, cli.Command)
|
||||
|
||||
checkCmd = func(cmdPath string, c cli.Command) {
|
||||
if len(c.Subcommands) != 0 {
|
||||
if c.Before != nil {
|
||||
t.Fatalf("Command %s does not expect to have a Before func since it is not the leaf command", cmdPath)
|
||||
}
|
||||
} else {
|
||||
if c.Before == nil {
|
||||
t.Fatalf("Command %s expects to have a Before func since it is a leaf command", cmdPath)
|
||||
}
|
||||
}
|
||||
|
||||
// Test subcommands
|
||||
for _, subCmd := range c.Subcommands {
|
||||
checkCmd(cmdPath+"/"+subCmd.Name, subCmd)
|
||||
}
|
||||
}
|
||||
|
||||
for _, cmd := range appCmds {
|
||||
checkCmd("", cmd)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -49,7 +49,7 @@ var mbCmd = cli.Command{
|
||||
Name: "mb",
|
||||
Usage: "make a bucket",
|
||||
Action: mainMakeBucket,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(mbFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
+84
-116
@@ -117,7 +117,7 @@ var mirrorCmd = cli.Command{
|
||||
Name: "mirror",
|
||||
Usage: "synchronize object(s) to a remote site",
|
||||
Action: mainMirror,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(append(mirrorFlags, ioFlags...), globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
@@ -213,17 +213,7 @@ type mirrorJob struct {
|
||||
sourceURL string
|
||||
targetURL string
|
||||
|
||||
isFake, isRemove, isOverwrite bool
|
||||
isWatch, isPreserve bool
|
||||
md5, disableMultipart bool
|
||||
olderThan, newerThan string
|
||||
storageClass string
|
||||
userMetadata map[string]string
|
||||
|
||||
excludeOptions []string
|
||||
encKeyDB map[string][]prefixSSEPair
|
||||
|
||||
activeActive bool
|
||||
opts mirrorOptions
|
||||
}
|
||||
|
||||
// mirrorMessage container for file mirror messages
|
||||
@@ -252,7 +242,7 @@ func (m mirrorMessage) JSON() string {
|
||||
|
||||
// doRemove - removes files on target.
|
||||
func (mj *mirrorJob) doRemove(ctx context.Context, sURLs URLs) URLs {
|
||||
if mj.isFake {
|
||||
if mj.opts.isFake {
|
||||
return sURLs.WithError(nil)
|
||||
}
|
||||
|
||||
@@ -285,7 +275,7 @@ func (mj *mirrorJob) doRemove(ctx context.Context, sURLs URLs) URLs {
|
||||
// doMirror - Mirror an object to multiple destination. URLs status contains a copy of sURLs and error if any.
|
||||
func (mj *mirrorJob) doMirrorWatch(ctx context.Context, targetPath string, tgtSSE encrypt.ServerSide, sURLs URLs) URLs {
|
||||
shouldQueue := false
|
||||
if !mj.isOverwrite && !mj.activeActive {
|
||||
if !mj.opts.isOverwrite && !mj.opts.activeActive {
|
||||
targetClient, err := newClient(targetPath)
|
||||
if err != nil {
|
||||
// cannot create targetclient
|
||||
@@ -299,7 +289,7 @@ func (mj *mirrorJob) doMirrorWatch(ctx context.Context, targetPath string, tgtSS
|
||||
} // doesn't exist
|
||||
shouldQueue = true
|
||||
}
|
||||
if shouldQueue || mj.isOverwrite || mj.activeActive {
|
||||
if shouldQueue || mj.opts.isOverwrite || mj.opts.activeActive {
|
||||
// adjust total, because we want to show progress of
|
||||
// the item still queued to be copied.
|
||||
mj.status.Add(sURLs.SourceContent.Size)
|
||||
@@ -321,7 +311,7 @@ func (mj *mirrorJob) doMirror(ctx context.Context, sURLs URLs) URLs {
|
||||
|
||||
// For a fake mirror make sure we update respective progress bars
|
||||
// and accounting readers under relevant conditions.
|
||||
if mj.isFake {
|
||||
if mj.opts.isFake {
|
||||
if sURLs.SourceContent != nil {
|
||||
mj.status.Add(sURLs.SourceContent.Size)
|
||||
}
|
||||
@@ -340,22 +330,23 @@ func (mj *mirrorJob) doMirror(ctx context.Context, sURLs URLs) URLs {
|
||||
// Initialize target metadata.
|
||||
sURLs.TargetContent.Metadata = make(map[string]string)
|
||||
|
||||
if mj.storageClass != "" {
|
||||
sURLs.TargetContent.Metadata["X-Amz-Storage-Class"] = mj.storageClass
|
||||
if mj.opts.storageClass != "" {
|
||||
sURLs.TargetContent.Metadata["X-Amz-Storage-Class"] = mj.opts.storageClass
|
||||
}
|
||||
|
||||
if mj.activeActive {
|
||||
if mj.opts.activeActive {
|
||||
srcModTime := getSourceModTimeKey(sURLs.SourceContent.Metadata)
|
||||
// If the source object already has source modtime attribute set, then
|
||||
// use it in target. Otherwise use the S3 modtime instead.
|
||||
if sURLs.SourceContent.Metadata[activeActiveSourceModTimeKey] != "" {
|
||||
sURLs.TargetContent.Metadata[activeActiveSourceModTimeKey] = sURLs.SourceContent.Metadata[activeActiveSourceModTimeKey]
|
||||
if srcModTime != "" {
|
||||
sURLs.TargetContent.Metadata[activeActiveSourceModTimeKey] = srcModTime
|
||||
} else {
|
||||
sURLs.TargetContent.Metadata[activeActiveSourceModTimeKey] = sURLs.SourceContent.Time.Format(time.RFC3339Nano)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize additional target user metadata.
|
||||
sURLs.TargetContent.UserMetadata = mj.userMetadata
|
||||
sURLs.TargetContent.UserMetadata = mj.opts.userMetadata
|
||||
|
||||
sourcePath := filepath.ToSlash(filepath.Join(sourceAlias, sourceURL.Path))
|
||||
targetPath := filepath.ToSlash(filepath.Join(targetAlias, targetURL.Path))
|
||||
@@ -366,9 +357,9 @@ func (mj *mirrorJob) doMirror(ctx context.Context, sURLs URLs) URLs {
|
||||
TotalCount: sURLs.TotalCount,
|
||||
TotalSize: sURLs.TotalSize,
|
||||
})
|
||||
sURLs.MD5 = mj.md5
|
||||
sURLs.DisableMultipart = mj.disableMultipart
|
||||
return uploadSourceToTargetURL(ctx, sURLs, mj.status, mj.encKeyDB, mj.isPreserve)
|
||||
sURLs.MD5 = mj.opts.md5
|
||||
sURLs.DisableMultipart = mj.opts.disableMultipart
|
||||
return uploadSourceToTargetURL(ctx, sURLs, mj.status, mj.opts.encKeyDB, mj.opts.isMetadata)
|
||||
}
|
||||
|
||||
// Update progress status
|
||||
@@ -395,7 +386,7 @@ func (mj *mirrorJob) monitorMirrorStatus() (errDuringMirror bool) {
|
||||
errorIf(sURLs.Error.Trace(), "Failed to perform mirroring.")
|
||||
errDuringMirror = true
|
||||
}
|
||||
if mj.activeActive {
|
||||
if mj.opts.activeActive {
|
||||
close(mj.stopCh)
|
||||
break
|
||||
}
|
||||
@@ -443,7 +434,7 @@ func (mj *mirrorJob) watchMirrorEvents(ctx context.Context, events []EventInfo)
|
||||
// joined to the targetURL.
|
||||
sourceSuffix := strings.TrimPrefix(eventPath, sourceURLFull)
|
||||
//Skip the object, if it matches the Exclude options provided
|
||||
if matchExcludeOptions(mj.excludeOptions, sourceSuffix) {
|
||||
if matchExcludeOptions(mj.opts.excludeOptions, sourceSuffix) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -452,7 +443,7 @@ func (mj *mirrorJob) watchMirrorEvents(ctx context.Context, events []EventInfo)
|
||||
// newClient needs the unexpanded path, newCLientURL needs the expanded path
|
||||
targetAlias, expandedTargetPath, _ := mustExpandAlias(targetPath)
|
||||
targetURL := newClientURL(expandedTargetPath)
|
||||
tgtSSE := getSSE(targetPath, mj.encKeyDB[targetAlias])
|
||||
tgtSSE := getSSE(targetPath, mj.opts.encKeyDB[targetAlias])
|
||||
|
||||
if (event.Type == EventCreate) ||
|
||||
(event.Type == EventCreateCopy) ||
|
||||
@@ -470,12 +461,13 @@ func (mj *mirrorJob) watchMirrorEvents(ctx context.Context, events []EventInfo)
|
||||
},
|
||||
TargetAlias: targetAlias,
|
||||
TargetContent: &ClientContent{URL: *targetURL},
|
||||
MD5: mj.md5,
|
||||
DisableMultipart: mj.disableMultipart,
|
||||
encKeyDB: mj.encKeyDB,
|
||||
MD5: mj.opts.md5,
|
||||
DisableMultipart: mj.opts.disableMultipart,
|
||||
encKeyDB: mj.opts.encKeyDB,
|
||||
}
|
||||
if mj.activeActive &&
|
||||
mirrorURL.SourceContent.Metadata[activeActiveSourceModTimeKey] != "" {
|
||||
if mj.opts.activeActive &&
|
||||
(getSourceModTimeKey(mirrorURL.SourceContent.Metadata) != "" ||
|
||||
getSourceModTimeKey(mirrorURL.SourceContent.UserMetadata) != "") {
|
||||
// If source has active-active attributes, it means that the
|
||||
// object was uploaded by "mc mirror", hence ignore the event
|
||||
// to avoid copying it.
|
||||
@@ -493,13 +485,13 @@ func (mj *mirrorJob) watchMirrorEvents(ctx context.Context, events []EventInfo)
|
||||
SourceContent: nil,
|
||||
TargetAlias: targetAlias,
|
||||
TargetContent: &ClientContent{URL: *targetURL},
|
||||
MD5: mj.md5,
|
||||
DisableMultipart: mj.disableMultipart,
|
||||
encKeyDB: mj.encKeyDB,
|
||||
MD5: mj.opts.md5,
|
||||
DisableMultipart: mj.opts.disableMultipart,
|
||||
encKeyDB: mj.opts.encKeyDB,
|
||||
}
|
||||
mirrorURL.TotalCount = mj.status.GetCounts()
|
||||
mirrorURL.TotalSize = mj.status.Get()
|
||||
if mirrorURL.TargetContent != nil && (mj.isRemove || mj.activeActive) {
|
||||
if mirrorURL.TargetContent != nil && (mj.opts.isRemove || mj.opts.activeActive) {
|
||||
mj.queueCh <- func() URLs {
|
||||
return mj.doRemove(ctx, mirrorURL)
|
||||
}
|
||||
@@ -551,8 +543,7 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
|
||||
mj.m.Lock()
|
||||
defer mj.m.Unlock()
|
||||
|
||||
isMetadata := len(mj.userMetadata) > 0 || mj.isPreserve
|
||||
URLsCh := prepareMirrorURLs(mj.sourceURL, mj.targetURL, mj.isFake, mj.isOverwrite, mj.isRemove, isMetadata, mj.excludeOptions, mj.encKeyDB)
|
||||
URLsCh := prepareMirrorURLs(ctx, mj.sourceURL, mj.targetURL, mj.opts)
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -567,10 +558,10 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
|
||||
}
|
||||
|
||||
if sURLs.SourceContent != nil {
|
||||
if mj.olderThan != "" && isOlder(sURLs.SourceContent.Time, mj.olderThan) {
|
||||
if isOlder(sURLs.SourceContent.Time, mj.opts.olderThan) {
|
||||
continue
|
||||
}
|
||||
if mj.newerThan != "" && isNewer(sURLs.SourceContent.Time, mj.newerThan) {
|
||||
if isNewer(sURLs.SourceContent.Time, mj.opts.newerThan) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -578,6 +569,7 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
|
||||
if sURLs.SourceContent != nil {
|
||||
mj.status.Add(sURLs.SourceContent.Size)
|
||||
}
|
||||
|
||||
mj.status.SetTotal(mj.status.Get()).Update()
|
||||
mj.status.AddCounts(1)
|
||||
|
||||
@@ -590,7 +582,7 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
|
||||
mj.queueCh <- func() URLs {
|
||||
return mj.doMirror(ctx, sURLs)
|
||||
}
|
||||
} else if sURLs.TargetContent != nil && mj.isRemove {
|
||||
} else if sURLs.TargetContent != nil && mj.opts.isRemove {
|
||||
mj.queueCh <- func() URLs {
|
||||
return mj.doRemove(ctx, sURLs)
|
||||
}
|
||||
@@ -611,7 +603,7 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// Starts watcher loop for watching for new events.
|
||||
if mj.isWatch {
|
||||
if mj.opts.isWatch {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@@ -629,7 +621,7 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
stopParallel := func() {
|
||||
if !mj.isWatch {
|
||||
if !mj.opts.isWatch {
|
||||
close(mj.queueCh)
|
||||
mj.parallel.wait()
|
||||
cancelMirror()
|
||||
@@ -648,32 +640,15 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc
|
||||
return mj.monitorMirrorStatus()
|
||||
}
|
||||
|
||||
func newMirrorJob(srcURL, dstURL string, isFake, isRemove, isOverwrite, isWatch, isPreserve, activeActive bool, excludeOptions []string, olderThan, newerThan string, storageClass string, userMetadata map[string]string, encKeyDB map[string][]prefixSSEPair, md5, disableMultipart bool) *mirrorJob {
|
||||
if activeActive {
|
||||
isPreserve = true
|
||||
}
|
||||
func newMirrorJob(srcURL, dstURL string, opts mirrorOptions) *mirrorJob {
|
||||
mj := mirrorJob{
|
||||
stopCh: make(chan struct{}),
|
||||
|
||||
sourceURL: srcURL,
|
||||
targetURL: dstURL,
|
||||
|
||||
isFake: isFake,
|
||||
isRemove: isRemove,
|
||||
isOverwrite: isOverwrite,
|
||||
isWatch: isWatch,
|
||||
isPreserve: isPreserve || activeActive,
|
||||
md5: md5,
|
||||
disableMultipart: disableMultipart,
|
||||
excludeOptions: excludeOptions,
|
||||
olderThan: olderThan,
|
||||
newerThan: newerThan,
|
||||
storageClass: storageClass,
|
||||
userMetadata: userMetadata,
|
||||
encKeyDB: encKeyDB,
|
||||
statusCh: make(chan URLs),
|
||||
watcher: NewWatcher(UTCNow()),
|
||||
activeActive: activeActive,
|
||||
opts: opts,
|
||||
statusCh: make(chan URLs),
|
||||
watcher: NewWatcher(UTCNow()),
|
||||
}
|
||||
|
||||
mj.parallel, mj.queueCh = newParallelManager(mj.statusCh)
|
||||
@@ -743,7 +718,7 @@ func getEventPathURLWin(srcURL, eventPath string) string {
|
||||
}
|
||||
|
||||
// runMirror - mirrors all buckets to another S3 server
|
||||
func runMirror(srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]prefixSSEPair) bool {
|
||||
func runMirror(ctx context.Context, cancelMirror context.CancelFunc, srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]prefixSSEPair) bool {
|
||||
// This is kept for backward compatibility, `--force` means
|
||||
// --overwrite.
|
||||
isOverwrite := cli.Bool("force")
|
||||
@@ -752,10 +727,10 @@ func runMirror(srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]pr
|
||||
}
|
||||
|
||||
// Parse metadata.
|
||||
userMetaMap := make(map[string]string)
|
||||
userMetadata := make(map[string]string)
|
||||
if cli.String("attr") != "" {
|
||||
var err *probe.Error
|
||||
userMetaMap, err = getMetaDataEntry(cli.String("attr"))
|
||||
userMetadata, err = getMetaDataEntry(cli.String("attr"))
|
||||
fatalIf(err, "Unable to parse attribute %v", cli.String("attr"))
|
||||
}
|
||||
|
||||
@@ -780,37 +755,29 @@ func runMirror(srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]pr
|
||||
}
|
||||
|
||||
// Create a new mirror job and execute it
|
||||
mj := newMirrorJob(srcURL, dstURL,
|
||||
cli.Bool("fake"),
|
||||
cli.Bool("remove"),
|
||||
isOverwrite,
|
||||
cli.Bool("watch"),
|
||||
cli.Bool("a"),
|
||||
cli.Bool("multi-master") || cli.Bool("active-active"),
|
||||
cli.StringSlice("exclude"),
|
||||
cli.String("older-than"),
|
||||
cli.String("newer-than"),
|
||||
cli.String("storage-class"),
|
||||
userMetaMap,
|
||||
encKeyDB,
|
||||
cli.Bool("md5"),
|
||||
cli.Bool("disable-multipart"),
|
||||
)
|
||||
|
||||
go func() {
|
||||
<-globalContext.Done()
|
||||
os.Exit(globalErrorExitStatus)
|
||||
}()
|
||||
|
||||
ctx, cancelMirror := context.WithCancel(globalContext)
|
||||
defer cancelMirror()
|
||||
mj := newMirrorJob(srcURL, dstURL, mirrorOptions{
|
||||
isFake: cli.Bool("fake"),
|
||||
isRemove: cli.Bool("remove"),
|
||||
isOverwrite: isOverwrite,
|
||||
isWatch: cli.Bool("watch") || cli.Bool("multi-master") || cli.Bool("active-active"),
|
||||
isMetadata: cli.Bool("a") || cli.Bool("multi-master") || cli.Bool("active-active") || len(userMetadata) > 0,
|
||||
md5: cli.Bool("md5"),
|
||||
disableMultipart: cli.Bool("disable-multipart"),
|
||||
excludeOptions: cli.StringSlice("exclude"),
|
||||
olderThan: cli.String("older-than"),
|
||||
newerThan: cli.String("newer-than"),
|
||||
storageClass: cli.String("storage-class"),
|
||||
userMetadata: userMetadata,
|
||||
encKeyDB: encKeyDB,
|
||||
activeActive: cli.Bool("multi-master") || cli.Bool("active-active"),
|
||||
})
|
||||
|
||||
if mirrorAllBuckets {
|
||||
// Synchronize buckets using dirDifference function
|
||||
for d := range dirDifference(srcClt, dstClt, srcURL, dstURL) {
|
||||
for d := range dirDifference(ctx, srcClt, dstClt, srcURL, dstURL) {
|
||||
if d.Error != nil {
|
||||
if mj.activeActive {
|
||||
errorIf(d.Error, "Failed to start mirroring.")
|
||||
if mj.opts.activeActive {
|
||||
errorIf(d.Error, "Failed to start mirroring.. retrying")
|
||||
return true
|
||||
}
|
||||
mj.status.fatalIf(d.Error, "Failed to start mirroring.")
|
||||
@@ -847,12 +814,12 @@ func runMirror(srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]pr
|
||||
"Unable to copy bucket policies to `"+newDstClt.GetURL().String()+"`.")
|
||||
}
|
||||
|
||||
if mj.isWatch {
|
||||
if mj.opts.isWatch {
|
||||
// monitor mode will watch the source folders for changes,
|
||||
// and queue them for copying.
|
||||
if err := mj.watchURL(ctx, newSrcClt); err != nil {
|
||||
if mj.activeActive {
|
||||
errorIf(err, "Failed to start monitoring.")
|
||||
if mj.opts.activeActive {
|
||||
errorIf(err, "Failed to start monitoring.. retrying")
|
||||
return true
|
||||
}
|
||||
mj.status.fatalIf(err, "Failed to start monitoring.")
|
||||
@@ -868,7 +835,7 @@ func runMirror(srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]pr
|
||||
|
||||
// Create bucket if it doesn't exist at destination.
|
||||
// ignore if already exists.
|
||||
if mj.activeActive {
|
||||
if mj.opts.activeActive {
|
||||
err = dstClt.MakeBucket(ctx, cli.String("region"), true, withLock)
|
||||
errorIf(err, "Unable to create bucket at `"+dstURL+"`.")
|
||||
if err != nil {
|
||||
@@ -883,31 +850,29 @@ func runMirror(srcURL, dstURL string, cli *cli.Context, encKeyDB map[string][]pr
|
||||
if mode != "" {
|
||||
err = dstClt.SetObjectLockConfig(ctx, mode, validity, unit)
|
||||
errorIf(err, "Unable to set object lock config in `"+dstURL+"`.")
|
||||
if err != nil && mj.activeActive {
|
||||
if err != nil && mj.opts.activeActive {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
err = copyBucketPolicies(ctx, srcClt, dstClt, isOverwrite)
|
||||
errorIf(err, "Unable to copy bucket policies to `"+dstClt.GetURL().String()+"`.")
|
||||
if err != nil && mj.activeActive {
|
||||
if err != nil && mj.opts.activeActive {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if !mirrorAllBuckets && mj.isWatch {
|
||||
if !mirrorAllBuckets && mj.opts.isWatch {
|
||||
// monitor mode will watch the source folders for changes,
|
||||
// and queue them for copying.
|
||||
if err := mj.watchURL(ctx, srcClt); err != nil {
|
||||
if mj.activeActive {
|
||||
errorIf(err, "Failed to start monitoring.")
|
||||
if mj.opts.activeActive {
|
||||
errorIf(err, "Failed to start monitoring.. retrying")
|
||||
return true
|
||||
}
|
||||
mj.status.fatalIf(err, "Failed to start monitoring.")
|
||||
}
|
||||
}
|
||||
|
||||
// Start mirroring job
|
||||
return mj.mirror(ctx, cancelMirror)
|
||||
}
|
||||
|
||||
@@ -940,16 +905,19 @@ func mainMirror(cliCtx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
if cliCtx.Bool("multi-master") || cliCtx.Bool("active-active") {
|
||||
for {
|
||||
runMirror(srcURL, tgtURL, cliCtx, encKeyDB)
|
||||
time.Sleep(time.Second * 2)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return exitStatus(globalErrorExitStatus)
|
||||
default:
|
||||
if errorDetected := runMirror(ctx, cancelMirror, srcURL, tgtURL, cliCtx, encKeyDB); errorDetected {
|
||||
if cliCtx.Bool("multi-master") || cliCtx.Bool("active-active") {
|
||||
time.Sleep(2 * time.Second)
|
||||
continue
|
||||
}
|
||||
return exitStatus(globalErrorExitStatus)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if errorDetected := runMirror(srcURL, tgtURL, cliCtx, encKeyDB); errorDetected {
|
||||
return exitStatus(globalErrorExitStatus)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+21
-10
@@ -70,9 +70,9 @@ func checkMirrorSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[st
|
||||
}
|
||||
|
||||
/****** Generic rules *******/
|
||||
if !cliCtx.Bool("watch") {
|
||||
if !cliCtx.Bool("watch") && !cliCtx.Bool("active-active") && !cliCtx.Bool("multi-master") {
|
||||
_, srcContent, err := url2Stat(ctx, srcURL, false, encKeyDB)
|
||||
// incomplete uploads are not necessary for copy operation, no need to verify for them.
|
||||
// incomplete uploads are not necessary for mirror operation, no need to verify for them.
|
||||
isIncomplete := false
|
||||
if err != nil && !isURLPrefixExists(srcURL, isIncomplete) {
|
||||
errorIf(err.Trace(srcURL), "Unable to stat source `"+srcURL+"`.")
|
||||
@@ -96,7 +96,7 @@ func matchExcludeOptions(excludeOptions []string, srcSuffix string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemove, isMetadata bool, excludeOptions []string, URLsCh chan<- URLs, encKeyDB map[string][]prefixSSEPair) {
|
||||
func deltaSourceTarget(ctx context.Context, sourceURL, targetURL string, opts mirrorOptions, URLsCh chan<- URLs) {
|
||||
// source and targets are always directories
|
||||
sourceSeparator := string(newClientURL(sourceURL).Separator)
|
||||
if !strings.HasSuffix(sourceURL, sourceSeparator) {
|
||||
@@ -126,7 +126,7 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
||||
}
|
||||
|
||||
// List both source and target, compare and return values through channel.
|
||||
for diffMsg := range objectDifference(sourceClnt, targetClnt, sourceURL, targetURL, isMetadata) {
|
||||
for diffMsg := range objectDifference(ctx, sourceClnt, targetClnt, sourceURL, targetURL, opts.isMetadata) {
|
||||
if diffMsg.Error != nil {
|
||||
// Send all errors through the channel
|
||||
URLsCh <- URLs{Error: diffMsg.Error}
|
||||
@@ -135,13 +135,13 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
||||
|
||||
srcSuffix := strings.TrimPrefix(diffMsg.FirstURL, sourceURL)
|
||||
//Skip the source object if it matches the Exclude options provided
|
||||
if matchExcludeOptions(excludeOptions, srcSuffix) {
|
||||
if matchExcludeOptions(opts.excludeOptions, srcSuffix) {
|
||||
continue
|
||||
}
|
||||
|
||||
tgtSuffix := strings.TrimPrefix(diffMsg.SecondURL, targetURL)
|
||||
//Skip the target object if it matches the Exclude options provided
|
||||
if matchExcludeOptions(excludeOptions, tgtSuffix) {
|
||||
if matchExcludeOptions(opts.excludeOptions, tgtSuffix) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
||||
case differInType:
|
||||
URLsCh <- URLs{Error: errInvalidTarget(diffMsg.SecondURL)}
|
||||
case differInSize, differInMetadata, differInAASourceMTime:
|
||||
if !isOverwrite && !isFake {
|
||||
if !opts.isOverwrite && !opts.isFake && !opts.activeActive {
|
||||
// Size or time or etag differs but --overwrite not set.
|
||||
URLsCh <- URLs{Error: errOverWriteNotAllowed(diffMsg.SecondURL)}
|
||||
continue
|
||||
@@ -181,7 +181,7 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
||||
TargetContent: targetContent,
|
||||
}
|
||||
case differInSecond:
|
||||
if !isRemove && !isFake {
|
||||
if !opts.isRemove && !opts.isFake {
|
||||
continue
|
||||
}
|
||||
URLsCh <- URLs{
|
||||
@@ -196,9 +196,20 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
||||
}
|
||||
}
|
||||
|
||||
type mirrorOptions struct {
|
||||
isFake, isOverwrite, activeActive bool
|
||||
isWatch, isRemove, isMetadata bool
|
||||
excludeOptions []string
|
||||
encKeyDB map[string][]prefixSSEPair
|
||||
md5, disableMultipart bool
|
||||
olderThan, newerThan string
|
||||
storageClass string
|
||||
userMetadata map[string]string
|
||||
}
|
||||
|
||||
// Prepares urls that need to be copied or removed based on requested options.
|
||||
func prepareMirrorURLs(sourceURL string, targetURL string, isFake, isOverwrite, isRemove, isMetadata bool, excludeOptions []string, encKeyDB map[string][]prefixSSEPair) <-chan URLs {
|
||||
func prepareMirrorURLs(ctx context.Context, sourceURL string, targetURL string, opts mirrorOptions) <-chan URLs {
|
||||
URLsCh := make(chan URLs)
|
||||
go deltaSourceTarget(sourceURL, targetURL, isFake, isOverwrite, isRemove, isMetadata, excludeOptions, URLsCh, encKeyDB)
|
||||
go deltaSourceTarget(ctx, sourceURL, targetURL, opts, URLsCh)
|
||||
return URLsCh
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ var mvCmd = cli.Command{
|
||||
Name: "mv",
|
||||
Usage: "move objects",
|
||||
Action: mainMove,
|
||||
Before: setGlobalsFromContext,
|
||||
Before: initBeforeRunningCmd,
|
||||
Flags: append(append(mvFlags, ioFlags...), globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user