[Notes] [Git][BuildGrid/buildgrid][master] upload_{file, directory}(): fix status messages



Title: GitLab

Santiago Gil pushed to branch master at BuildGrid / buildgrid

Commits:

1 changed file:

Changes:

  • buildgrid/_app/commands/cmd_cas.py
    ... ... @@ -82,20 +82,19 @@ def upload_dummy(context):
    82 82
                   help="Check uploaded files integrity.")
    
    83 83
     @pass_context
    
    84 84
     def upload_file(context, file_path, verify):
    
    85
    -    sent_digests, files_map = [], {}
    
    85
    +    sent_digests = []
    
    86 86
         with upload(context.channel, instance=context.instance_name) as uploader:
    
    87 87
             for path in file_path:
    
    88 88
                 if not os.path.isabs(path):
    
    89
    -                path = os.path.abspath(path)
    
    89
    +                path = os.path.relpath(path)
    
    90
    +
    
    90 91
                 click.echo("Queueing path=[{}]".format(path))
    
    91 92
     
    
    92 93
                 file_digest = uploader.upload_file(path, queue=True)
    
    93 94
     
    
    94
    -            files_map[file_digest.hash] = path
    
    95
    -            sent_digests.append(file_digest)
    
    95
    +            sent_digests.append((file_digest, path))
    
    96 96
     
    
    97
    -    for file_digest in sent_digests:
    
    98
    -        file_path = os.path.relpath(files_map[file_digest.hash])
    
    97
    +    for file_digest, file_path in sent_digests:
    
    99 98
             if verify and file_digest.size_bytes != os.stat(file_path).st_size:
    
    100 99
                 click.echo("Error: Failed to verify '{}'".format(file_path), err=True)
    
    101 100
             elif file_digest.ByteSize():
    
    ... ... @@ -111,22 +110,17 @@ def upload_file(context, file_path, verify):
    111 110
                   help="Check uploaded directory's integrity.")
    
    112 111
     @pass_context
    
    113 112
     def upload_directory(context, directory_path, verify):
    
    114
    -    sent_digests, nodes_map = [], {}
    
    113
    +    sent_digests = []
    
    115 114
         with upload(context.channel, instance=context.instance_name) as uploader:
    
    116 115
             for node, blob, path in merkle_tree_maker(directory_path):
    
    117
    -            if not os.path.isabs(path):
    
    118
    -                path = os.path.abspath(path)
    
    116
    +            if not os.path.isabs(directory_path):
    
    117
    +                path = os.path.relpath(path)
    
    119 118
                 click.echo("Queueing path=[{}]".format(path))
    
    120 119
     
    
    121 120
                 node_digest = uploader.put_blob(blob, digest=node.digest, queue=True)
    
    121
    +            sent_digests.append((node_digest, path))
    
    122 122
     
    
    123
    -            nodes_map[node.digest.hash] = path
    
    124
    -            sent_digests.append(node_digest)
    
    125
    -
    
    126
    -    for node_digest in sent_digests:
    
    127
    -        node_path = nodes_map[node_digest.hash]
    
    128
    -        if not os.path.isabs(directory_path):
    
    129
    -            node_path = os.path.relpath(node_path)
    
    123
    +    for node_digest, node_path in sent_digests:
    
    130 124
             if verify and (os.path.isfile(node_path) and
    
    131 125
                            node_digest.size_bytes != os.stat(node_path).st_size):
    
    132 126
                 click.echo("Error: Failed to verify path=[{}]".format(node_path), err=True)
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]