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

Method move_file

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

Source from the content-addressed store, hash-verified

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