diff --git a/tuf/README.md b/tuf/README.md index 4a40a254..ea317886 100644 --- a/tuf/README.md +++ b/tuf/README.md @@ -250,9 +250,10 @@ $ mkdir django; echo 'file4' > django/file4.txt # In the example below, file permissions of the target (octal number specifying file # access for owner, group, others (e.g., 0755) is added alongside the default fileinfo. # All target objects in metadata include the target's filepath, hash, and length. ->>> octal_file_permissions = oct(os.stat(target2_filepath).st_mode)[4:] +>>> target3_filepath = "path/to/repository/targets/file3.txt" +>>> octal_file_permissions = oct(os.stat(target3_filepath).st_mode)[4:] >>> custom_file_permissions = {'file_permissions': octal_file_permissions} ->>> repository.targets.add_target("path/to/repository/targets/file3.txt", custom_file_permissions) +>>> repository.targets.add_target(target3_filepath, custom_file_permissions) # The private key of the updated targets metadata must be loaded before it can be signed and # written (Note the load_repository() call above). diff --git a/tuf/client/updater.py b/tuf/client/updater.py index 5f7d4802..da836130 100755 --- a/tuf/client/updater.py +++ b/tuf/client/updater.py @@ -2615,7 +2615,10 @@ def updated_targets(self, targets, destination_directory): for target in targets: # Get the target's filepath located in 'destination_directory'. # We will compare targets against this file. - target_filepath = os.path.join(destination_directory, target['filepath']) + filepath = target['filepath'] + if filepath[0] == '/': + filepath = filepath[1:] + target_filepath = os.path.join(destination_directory, filepath) if target_filepath in updated_targetpaths: continue