mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Local exports are no longer blocked by missing local library
This commit is contained in:
1 parent
dd82fa99bb
commit
1a28ad6102
7 files changed
+105
-24
No files matched your search
@@ -106,6 +106,8 @@ CLOUD_SYNCED = "cloud_synced"
|
||||
UNREADABLE = "unreadable"
|
||||
#: Why a push cannot run.
|
||||
BLOCKED_NO_TARGET = "no_target"
|
||||
#: Every library the set names is missing on THIS computer.
|
||||
BLOCKED_NONE_HERE = "no_library_here"
|
||||
BLOCKED_EMPTY = "nothing_to_push"
|
||||
BLOCKED_UNAVAILABLE = "target_unavailable"
|
||||
BLOCKED_RUNNING = "app_running"
|
||||
@@ -337,8 +339,16 @@ class TargetPlan:
|
||||
#: Overwrite: the other sets pushed into this library, which it removes.
|
||||
wipes_sets: list[str] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def skipped(self) -> bool:
|
||||
"""Not on this computer, so passed over rather than blocking: a set's
|
||||
targets are shared by every computer that opens the library (a
|
||||
remote's sets live on its server), and one with only Traktor must
|
||||
still push a Traktor + rekordbox set."""
|
||||
return self.blocked == NOT_FOUND
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
return dict(self.__dict__)
|
||||
return {**self.__dict__, "skipped": self.skipped}
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -358,6 +368,11 @@ class PushPlan:
|
||||
def tracks(self) -> list[PlannedTrack]:
|
||||
return self.audio.tracks
|
||||
|
||||
@property
|
||||
def active(self) -> list[TargetPlan]:
|
||||
"""The targets this push writes: every one found on this computer."""
|
||||
return [t for t in self.targets if not t.skipped]
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
audio = self.audio
|
||||
free = free_bytes(audio.destination) if audio.destination else None
|
||||
@@ -454,11 +469,13 @@ def plan(adapter, export_set, *, store=None, level: Level | None = None,
|
||||
previous=previous)
|
||||
if not targets:
|
||||
out.blocked = BLOCKED_NO_TARGET
|
||||
elif not out.active:
|
||||
out.blocked = BLOCKED_NONE_HERE
|
||||
elif not built.exportable:
|
||||
out.blocked = BLOCKED_EMPTY
|
||||
elif any(t.blocked for t in targets):
|
||||
elif any(t.blocked for t in out.active):
|
||||
out.blocked = BLOCKED_UNAVAILABLE
|
||||
elif any(t.running for t in targets):
|
||||
elif any(t.running for t in out.active):
|
||||
out.blocked = BLOCKED_RUNNING
|
||||
return out
|
||||
|
||||
@@ -521,7 +538,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
See the module docstring for the order and what a cancel leaves."""
|
||||
if built.blocked:
|
||||
raise PushRefused(f"This push cannot run: {built.blocked}")
|
||||
for target in built.targets:
|
||||
for target in built.active:
|
||||
_refuse_if_running(target.platform)
|
||||
|
||||
root = Path(built.audio.destination)
|
||||
@@ -580,7 +597,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
playlists=built.playlists, checkpoint=_checkpoint(handle))
|
||||
|
||||
results = []
|
||||
for target in built.targets:
|
||||
for target in built.active:
|
||||
handle.raise_if_cancelled()
|
||||
handle.progress(done=0, total=0, unit="tracks",
|
||||
message=f"Pushing into {target.name}…")
|
||||
@@ -610,6 +627,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
"deleted_files": removed,
|
||||
"audio_root": str(root),
|
||||
"targets": results,
|
||||
"skipped_targets": [t.name for t in built.targets if t.skipped],
|
||||
}
|
||||
except BaseException:
|
||||
for partial, _final in waiting:
|
||||
|
||||
@@ -539,6 +539,9 @@ class PushTargetOut(BaseModel):
|
||||
name: str
|
||||
path: str | None = None
|
||||
blocked: str | None = None
|
||||
#: Not on this computer (`blocked` = not_found): passed over by the push
|
||||
#: instead of blocking it.
|
||||
skipped: bool = False
|
||||
running: bool = False
|
||||
add: int = 0
|
||||
already: int = 0
|
||||
@@ -565,7 +568,8 @@ class PushPreview(BaseModel):
|
||||
to_measure: int = 0
|
||||
level_counts: dict[str, int] = {}
|
||||
targets: list[PushTargetOut] = []
|
||||
#: A FACT: `no_target`, `nothing_to_push`, `target_unavailable`,
|
||||
#: A FACT: `no_target`, `no_library_here` (none of the set's libraries
|
||||
#: is on this computer), `nothing_to_push`, `target_unavailable`,
|
||||
#: `app_running`, or null when it can run.
|
||||
blocked: str | None = None
|
||||
|
||||
|
||||
Reference in new issue
Block a user