Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzCopy Code Review #1

Closed
wants to merge 271 commits into from
Closed

AzCopy Code Review #1

wants to merge 271 commits into from

Conversation

prjain-msft
Copy link
Contributor

No description provided.

@zezha-msft
Copy link
Contributor

Please consider squashing some of these commits together, so that it's easier to review each concrete change. 😃

cmd/cancel.go Outdated
cancelCmd := &cobra.Command{
Use: "cancel",
SuggestFor: []string{"cancl", "ancl", "cacl"},
Short: "cancel cancels the existing job for given JobId",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancel cancels an existing job

cmd/cancel.go Outdated
Use: "cancel",
SuggestFor: []string{"cancl", "ancl", "cacl"},
Short: "cancel cancels the existing job for given JobId",
Long: `cancel cancels the existing job for given JobId`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancel cancels an existing job

cmd/cancel.go Outdated
Short: "cancel cancels the existing job for given JobId",
Long: `cancel cancels the existing job for given JobId`,
Args: func(cmd *cobra.Command, args []string) error {
// the cancel command requires necessarily to have an argument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// the cancel command requires a JobId argument; it then cancels all parts of the specified job.

cmd/cancel.go Outdated

// If no argument is passed then it is not valid
if len(args) != 1 {
return errors.New("this command only requires jobId")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should talk about how errors are presented to the user. This is fine for now, but we can't ship like this.

SuggestFor: []string{"cpy", "cy", "mv"}, //TODO why does message appear twice on the console
Short: "copy(cp) moves data between two places.",
Short: "copy(cp) moves data between two places.",
Copy link
Member

@JeffreyRichter JeffreyRichter Feb 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't say "copy moves" as this indicates that copy doesn't "copy" and that it "moves" instead. At some point, we should get Sercan and go through all of this. Maybe we also get Roy, the doc guy to work with us on this.

cmd/pause.go Outdated
pauseCmd := &cobra.Command{
Use: "pause",
SuggestFor: []string{"pase", "ause", "paue"},
Short: "pause pauses the existing job for given JobId",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing an article in these sentences: "pause pauses the existing job for the specified JobId"

"github.com/Azure/azure-storage-azcopy/common"
"net/url"
"os"
)

func determineLocaltionType(stringToParse string) common.LocationType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this method lowercase (private) and IsLocalPath & IsURL uppercase (public)?
If the 2 IsXxx methods are only ever called by determineLocationType (spelled wrong, by the way), then define them inside the determineLocationType function itself.

@@ -42,14 +42,14 @@ func IsLocalPath(path string) bool {
_, err := os.Stat(path)
// in case the path does not exist yet, an err is returned
// we need to make sure that it is indeed just a local path that does not exist yet, and not a url
if err == nil || (!IsUrl(path) && os.IsNotExist(err)){
if err == nil || (!IsUrl(path) && os.IsNotExist(err)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just "return err = nil || (!IsURL(path) && os.IsNotExist(err)" and then kill the braces and the return true & return false

@@ -61,4 +61,4 @@ func IsUrl(givenUrl string) bool{
return false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just return !(u.Host == "" || u.Scheme == "" || u.Path == "")

)
type JobID string //todo -- to uuid

type JobID UUID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let be consistent everywhere with casing: JobID or JobId -- I think JobID is better (as per http://www.dictionary.com/browse/id?s=t).


type JobID UUID

func (j JobID) String() (string){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function necessary? Maybe if JobID doesn't have String, it will automatically call String on the UUID type? I'm not sure myself.

type TransferStatus uint32

func (status TransferStatus) String() (statusString string) {
switch uint32(status) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of the switch cast and integers in the cases -- use case with constants instead.
If you are defining a data type (like TransferStatus), then use that data type; avoid casting it away. Casting it away defeats the whole purpose.

func (status TransferStatus) String() (statusString string) {
switch uint32(status) {
case 0:
return "InProgress"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these strings appear? Are they customer facing? logging? Both? If customer facing, then I'm sure we don't want something like "TransferComplete" without a space.

// Transfer has failed due to some error. This status does represent the state when transfer is cancelled
TransferFailed TransferStatus = 2

// Transfer is any of the three possible state (InProgress, Completer or Failed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is this used again? It is very strange to me. Also TransferStatus is a uint32 now not a byte so maybe we want a different value here? Maybe we should do this a different way?

TransferAny TransferStatus = TransferStatus(254)
)

func TransferStatusStringToCode(statusString string) TransferStatus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? If we really do need it, then the strings should be defined once as constants and re-used otherwise a spelling change in one place breaks the other place. Another way to go is to initialize a map[status]string and initialize it with number/string pairs. Then, getting the string from number is trivial and getting the number from string requires a for range loop which is slower but probably less commonly done.

}

type LogLevel pipeline.LogLevel
const (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for any of this; just use pipeline.LogLevel and its constants directly. Also, why have String()?

@@ -37,7 +129,7 @@ type CopyCmdArgsAndFlags struct {
Destination string

// inferred from arguments
SourceType LocationType
SourceType LocationType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the comment here because github won't let me put the comment on line 146. I think we want to define a type Metadata string for Metadata when used in a JobPartPlan. Then, you can easily add a method that converts it to an azblob.Metadata type so it can be passed into PutBlob/PutBlock method.

@@ -63,15 +155,16 @@ type CopyCmdArgsAndFlags struct {

// ListCmdArgsAndFlags represents the raw list command input from the user
type ListCmdArgsAndFlags struct {
JobId string
TransferStatus string
JobId string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a UUID? In the code you want to parse command line strings into specific data types as soon as possible to get the value of type safety in your code base as quickly as possible.

JobId string
TransferStatus string
JobId string
OfStatus string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a specific data type too, right?

prjain-msft added a commit that referenced this pull request Jun 22, 2018
…xecuting chunk func. the changes are added only for debug purpose #1
@zezha-msft zezha-msft closed this Jun 27, 2018
prjain-msft added a commit that referenced this pull request Aug 20, 2018
@adreed-msft adreed-msft mentioned this pull request Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants