MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / move_file

Method move_file

libatomic/src/daemon/services.rs:1865–2001  ·  view source on GitHub ↗
(
        &self,
        request: Request<MoveFileRequest>,
    )

Source from the content-addressed store, hash-verified

1863 }
1864
1865 async fn move_file(
1866 &self,
1867 request: Request<MoveFileRequest>,
1868 ) -> Result<Response<MoveFileResponse>, Status> {
1869 let request = request.into_inner();
1870 let handle = self
1871 .state
1872 .resolve(request.repository.as_ref().unwrap_or(&default_ref()))?;
1873 self.state.log_rpc("MoveFile", Some(&handle));
1874 let gate_handle = handle.clone();
1875 let _gate = gate_handle.exclusive().await;
1876 let result = tokio::task::spawn_blocking(move || -> Result<MoveFileResponse, Status> {
1877 let (repo, workspace) = handle.workspace_repository(if request.dry_run {
1878 atomic_repository::WorkspaceTxnMode::Observe
1879 } else {
1880 atomic_repository::WorkspaceTxnMode::Reconcile
1881 })?;
1882 let working_copy = workspace.working_copy();
1883 // The CLI's exact validation chain, with the domain's own
1884 // refusal vocabulary riding the stable error codes.
1885 if !repo.is_tracked(&request.source).map_err(repository_error)? {
1886 return Err(domain_status(
1887 ErrorCode::NotFound,
1888 format!("file not tracked: {}", request.source),
1889 ));
1890 }
1891 let source_path = handle.root.join(&request.source);
1892 if !source_path.exists() {
1893 return Err(domain_status(
1894 ErrorCode::NotFound,
1895 format!("file not found: {}", source_path.display()),
1896 ));
1897 }
1898 if repo
1899 .is_tracked(&request.destination)
1900 .map_err(repository_error)?
1901 {
1902 return Err(domain_status(
1903 ErrorCode::InvalidArgument,
1904 format!("destination already tracked: {}", request.destination),
1905 ));
1906 }
1907 if source_path.is_dir() {
1908 return Err(domain_status(
1909 ErrorCode::InvalidArgument,
1910 "directory moves are not yet supported; move tracked files individually",
1911 ));
1912 }
1913 let destination_path = handle.root.join(&request.destination);
1914 let destination_metadata = std::fs::symlink_metadata(&destination_path).ok();
1915 if destination_metadata.is_some() && !request.force {
1916 return Err(domain_status(
1917 ErrorCode::InvalidArgument,
1918 "destination exists; use --force only for untracked content",
1919 ));
1920 }
1921 if destination_metadata
1922 .as_ref()

Callers

nothing calls this directly

Calls 15

default_refFunction · 0.85
domain_statusFunction · 0.85
as_refMethod · 0.80
log_rpcMethod · 0.80
exclusiveMethod · 0.80
workspace_repositoryMethod · 0.80
is_trackedMethod · 0.80
is_dirMethod · 0.80
parentMethod · 0.80
repository_errorFunction · 0.70
into_innerMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected