[Notes] [Git][BuildStream/buildstream][jmac/cas_to_cas_oct] Don't forcbily create directories in _resolve in all cases



Title: GitLab

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

Commits:

1 changed file:

Changes:

  • buildstream/storage/_casbaseddirectory.py
    ... ... @@ -288,7 +288,7 @@ class CasBasedDirectory(Directory):
    288 288
                     return entry.descend(subdirectory_spec[1:], create)
    
    289 289
                 else:
    
    290 290
                     # May be a symlink
    
    291
    -                target = self._resolve(subdirectory_spec[0])
    
    291
    +                target = self._resolve(subdirectory_spec[0], force_create=create)
    
    292 292
                     if isinstance(target, CasBasedDirectory):
    
    293 293
                         return target
    
    294 294
                     error = "Cannot descend into {}, which is a '{}' in the directory {}"
    
    ... ... @@ -381,7 +381,7 @@ class CasBasedDirectory(Directory):
    381 381
             return directory
    
    382 382
     
    
    383 383
         
    
    384
    -    def _resolve(self, name, absolute_symlinks_resolve=True):
    
    384
    +    def _resolve(self, name, absolute_symlinks_resolve=True, force_create=False):
    
    385 385
             """ Resolves any name to an object. If the name points to a symlink in
    
    386 386
             this directory, it returns the thing it points to,
    
    387 387
             recursively. Returns a CasBasedDirectory, FileNode or
    
    ... ... @@ -441,14 +441,21 @@ class CasBasedDirectory(Directory):
    441 441
                         else:
    
    442 442
                             # This is a file or None (i.e. broken symlink)
    
    443 443
                             print("  resolving {}: file/broken link".format(c))
    
    444
    -                        if components:
    
    444
    +                        if f is None and force_create:
    
    445
    +                            print("Creating target of broken link {}".format(c))
    
    446
    +                            return directory.descend(c, create=True)
    
    447
    +                        elif components:
    
    445 448
                                 # Oh dear. We have components left to resolve, but the one we're trying to resolve points to a file.
    
    446 449
                                 raise VirtualDirectoryError("Reached a file called {} while trying to resolve a symlink; cannot proceed".format(c))
    
    447 450
                             else:
    
    448 451
                                 return f
    
    449 452
                     else:
    
    450
    -                    print("  resolving {}: Broken symlink".format(c))
    
    451
    -                    return None
    
    453
    +                    print("  resolving {}: Non-existent file; must be from a broken symlink.".format(c))
    
    454
    +                    if force_create:
    
    455
    +                        print("Creating target of broken link {} (2)".format(c))
    
    456
    +                        return directory.descend(c, create=True)
    
    457
    +                    else:
    
    458
    +                        return None
    
    452 459
     
    
    453 460
             # Shouldn't get here.
    
    454 461
             
    



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