Fix #104263: Error performing BAT pack in Windows with shared storage

Replace calls to `Path.absolute()` and `Path.resolve()` with
`bpathlib.make_absolute(path)`.

The replaced functions can transform drive letters on Windows to UNC
notation. Either all of Flamenco + BAT should be using UNC notation, or
drive letters, but mixing those will cause errors.
This commit is contained in:
Sybren A. Stüvel 2024-01-05 11:23:49 +01:00
parent b34ad8da90
commit a6f6f10239
4 changed files with 16 additions and 10 deletions

@ -29,6 +29,7 @@ from collections import deque
from pathlib import Path
from . import time_tracker
from .submodules import bpathlib
CACHE_ROOT = Path().home() / ".cache/shaman-client/shasums"
MAX_CACHE_FILES_AGE_SECS = 3600 * 24 * 60 # 60 days
@ -93,7 +94,7 @@ def _cache_path(filepath: Path) -> Path:
"""Compute the cache file for the given file path."""
fs_encoding = sys.getfilesystemencoding()
filepath = filepath.absolute()
filepath = bpathlib.make_absolute(filepath)
# Reverse the directory, because most variation is in the last bytes.
rev_dir = str(filepath.parent)[::-1]

@ -131,10 +131,10 @@ def is_file_inside_job_storage(context: bpy.types.Context, blendfile: Path) -> b
the job storage dir is accessible by the workers already.
"""
blendfile = blendfile.absolute().resolve()
blendfile = bpathlib.make_absolute(blendfile)
prefs = preferences.get(context)
job_storage = Path(prefs.job_storage).absolute().resolve()
job_storage = bpathlib.make_absolute(Path(prefs.job_storage))
log.info("Checking whether the file is already inside the job storage")
log.info(" file : %s", blendfile)

@ -383,7 +383,11 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
self.log.info(
"File is not already in job storage location, copying it there"
)
self.blendfile_on_farm = self._bat_pack_filesystem(context, blendfile)
try:
self.blendfile_on_farm = self._bat_pack_filesystem(context, blendfile)
except FileNotFoundError:
self._quit(context)
return {"CANCELLED"}
context.window_manager.modal_handler_add(self)
wm = context.window_manager
@ -403,12 +407,11 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
# Get project path from addon preferences.
prefs = preferences.get(context)
project_path: Path = prefs.project_root()
try:
project_path = Path(bpy.path.abspath(str(project_path))).resolve()
except FileNotFoundError:
# Path.resolve() will raise a FileNotFoundError if the project path doesn't exist.
project_path = bpathlib.make_absolute(Path(bpy.path.abspath(str(project_path))))
if not project_path.exists():
self.report({"ERROR"}, "Project path %s does not exist" % project_path)
raise # TODO: handle this properly.
raise FileNotFoundError()
# Determine where the blend file will be stored.
unique_dir = "%s-%s" % (

@ -5,6 +5,8 @@ from pathlib import Path
from typing import Callable, TypeAlias
import dataclasses
from .bat.submodules import bpathlib
def for_blendfile(blendfile: Path, strategy: str) -> Path:
"""Return what is considered to be the project directory containing the given file.
@ -43,7 +45,7 @@ def _finder_subversion(blendfile: Path) -> Path:
def _search_path_marker(blendfile: Path, marker_path: str) -> Path:
"""Go up the directory hierarchy until a file or directory 'marker_path' is found."""
blendfile_dir = blendfile.absolute().parent
blendfile_dir = bpathlib.make_absolute(blendfile).parent
directory = blendfile_dir
while True: