Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/murfey/client/multigrid_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ def _start_rsyncer(
restarted: bool = False,
):
log.info(f"starting rsyncer: {source}")
if transfer:
# Always make sure the destination directory exists
make_directory_url = (
f"{self.murfey_url}/sessions/{self.session_id}/make_rsyncer_destination"
)
capture_post(make_directory_url, json={"destination": destination})
if self._environment:
self._environment.default_destinations[source] = destination
if self._environment.gain_ref and visit_path:
Expand Down
4 changes: 4 additions & 0 deletions src/murfey/client/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ def _start_rsyncer(
rsync_url: str = "",
):
log.info(f"starting rsyncer: {source}")
if transfer:
# Always make sure the destination directory exists
make_directory_url = f"{str(self._url.geturl())}/sessions/{str(self._environment.murfey_session)}/make_rsyncer_destination"
capture_post(make_directory_url, json={"destination": destination})
if self._environment:
self._environment.default_destinations[source] = destination
if self._environment.gain_ref and visit_path:
Expand Down
18 changes: 18 additions & 0 deletions src/murfey/server/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,24 @@ def suggest_path(
return {"suggested_path": check_path.relative_to(machine_config.rsync_basepath)}


@router.post("/{session_id}/make_rsyncer_destination")
def make_rsyncer_destination(session_id: int, destination: Path, db=murfey_db):
secure_path_parts = [secure_filename(p) for p in destination.parts]
destination_path = "/".join(secure_path_parts)
instrument_name = (
db.exec(select(Session).where(Session.id == session_id)).one().instrument_name
)
machine_config = get_machine_config(instrument_name=instrument_name)[
instrument_name
]
if not machine_config:
raise ValueError("No machine configuration set when making rsyncer destination")
full_destination_path = machine_config.rsync_basepath / destination_path
for parent_path in full_destination_path.parents:
parent_path.mkdir(mode=0o750, exist_ok=True)
return destination


@router.get("/sessions/{session_id}/data_collection_groups")
def get_dc_groups(
session_id: MurfeySessionID, db=murfey_db
Expand Down
Loading