[Notes] [Git][BuildStream/buildstream][jmac/cache_artifacts_with_vdir] 2 commits: Directory: Polish to fast_directory_import



Title: GitLab

Jim MacArthur pushed to branch jmac/cache_artifacts_with_vdir at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • buildstream/storage/_casbaseddirectory.py
    ... ... @@ -849,16 +849,14 @@ class CasBasedDirectory(Directory):
    849 849
             return total
    
    850 850
     
    
    851 851
         def fast_directory_import(self, dirname, other_directory):
    
    852
    -        # Fast import system. This creates a subdirectory in this directory which is equivalent to other_directory.
    
    853
    -        # 'dirname' must not exist in this directory.
    
    854 852
             assert dirname not in self.index
    
    855 853
             if isinstance(other_directory, CasBasedDirectory):
    
    856 854
                 filenode = self.pb2_directory.directories.add(digest=other_directory.pb_object.digest, name=dirname)
    
    857 855
                 self.index[dirname] = IndexEntry(other_directory.pb_object, buildstream_object=other_directory.buildstream_object)
    
    858 856
             else:
    
    859 857
                 # Revert to the old method.
    
    860
    -            subdir = assemblevdir.descend("files", create=True)
    
    861
    -            subdir.import_files(collectvdir, can_link=True)
    
    858
    +            subdir = self.descend(dirname, create=True)
    
    859
    +            subdir.import_files(other_directory, can_link=True)
    
    862 860
     
    
    863 861
         def _get_identifier(self):
    
    864 862
             path = ""
    

  • buildstream/storage/_filebaseddirectory.py
    ... ... @@ -125,6 +125,13 @@ class FileBasedDirectory(Directory):
    125 125
             self._mark_changed()
    
    126 126
             return import_result
    
    127 127
     
    
    128
    +    def fast_directory_import(self, dirname, other_directory):
    
    129
    +        # We can't do a fast import into a FileBasedDirectory, so this
    
    130
    +        # falls back to import_files.
    
    131
    +        assert dirname not in self.index
    
    132
    +        subdir = self.descend(dirname, create=True)
    
    133
    +        subdir.import_files(other_directory, can_link=True)
    
    134
    +
    
    128 135
         def _mark_changed(self):
    
    129 136
             self._directory_read = False
    
    130 137
     
    

  • buildstream/storage/directory.py
    ... ... @@ -99,6 +99,30 @@ class Directory():
    99 99
     
    
    100 100
             raise NotImplementedError()
    
    101 101
     
    
    102
    +    def fast_directory_import(self, dirname, other_directory):
    
    103
    +        """Import other_directory as a new directory in this one.
    
    104
    +
    
    105
    +        This is a potentially faster method than import_directory with
    
    106
    +        fewer options. dirname must not already exist, and all files
    
    107
    +        are imported unconditionally. It is assumed that it is
    
    108
    +        acceptable to use filesystem hard links to files in
    
    109
    +        other_directory. You cannot update utimes or get a
    
    110
    +        FileListResult.
    
    111
    +
    
    112
    +        This only provides a benefit if both this and other_directory
    
    113
    +        are CAS-based directories. In other cases, it will fall back
    
    114
    +        to import_directory.
    
    115
    +
    
    116
    +        Args:
    
    117
    +          dirname: The name to call the subdirectory in this
    
    118
    +          directory. This must not already exist in this directory.
    
    119
    +
    
    120
    +          other_directory: The directory to import.
    
    121
    +
    
    122
    +        """
    
    123
    +
    
    124
    +        raise NotImplementedError()
    
    125
    +
    
    102 126
         def export_files(self, to_directory, *, can_link=False, can_destroy=False):
    
    103 127
             """Copies everything from this into to_directory.
    
    104 128
     
    



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