@@ -394,50 +394,60 @@ impl RemoteFile {
394394 unsafe { BnString :: into_string ( result) }
395395 }
396396
397- // TODO: AsRef<Path>
398- /// Download a file from its remote, saving all snapshots to a database in the
399- /// specified location. Returns a FileContext for opening the file later.
397+ /// Download a remote file and possibly dependencies to its project
398+ /// Dependency download behavior depends on the value of the collaboration.autoDownloadFileDependencies setting
400399 ///
401- /// * `db_path` - File path for saved database
402- /// * `progress_function` - Function to call for progress updates
403- pub fn download ( & self , db_path : & Path ) -> Result < Ref < FileMetadata > , ( ) > {
404- sync:: download_file ( self , db_path)
400+ /// * `progress` - Function to call on progress updates
401+ pub fn download ( & self ) -> Result < ( ) , ( ) > {
402+ self . download_with_progress ( NoProgressCallback )
405403 }
406404
407- // TODO: AsRef<Path>
408- /// Download a file from its remote, saving all snapshots to a database in the
409- /// specified location. Returns a FileContext for opening the file later.
405+ /// Download a remote file and possibly dependencies to its project
406+ /// Dependency download behavior depends on the value of the collaboration.autoDownloadFileDependencies setting
410407 ///
411- /// * `db_path` - File path for saved database
412- /// * `progress_function` - Function to call for progress updates
413- pub fn download_with_progress < F > (
414- & self ,
415- db_path : & Path ,
416- progress_function : F ,
417- ) -> Result < Ref < FileMetadata > , ( ) >
408+ /// * `progress` - Function to call on progress updates
409+ pub fn download_with_progress < P > ( & self , mut progress : P ) -> Result < ( ) , ( ) >
418410 where
419- F : ProgressCallback ,
411+ P : ProgressCallback ,
420412 {
421- sync:: download_file_with_progress ( self , db_path, progress_function)
413+ let success = unsafe {
414+ BNRemoteFileDownload (
415+ self . handle . as_ptr ( ) ,
416+ Some ( P :: cb_progress_callback) ,
417+ & mut progress as * mut P as * mut c_void ,
418+ )
419+ } ;
420+ success. then_some ( ( ) ) . ok_or ( ( ) )
422421 }
423422
424423 /// Download a remote file and save it to a BNDB at the given `path`, returning the associated [`FileMetadata`].
425- pub fn download_database ( & self , path : & Path ) -> Result < Ref < FileMetadata > , ( ) > {
426- let file = self . download ( path) ?;
427- let database = file. database ( ) . ok_or ( ( ) ) ?;
428- self . sync ( & database, DatabaseConflictHandlerFail , NoNameChangeset ) ?;
429- Ok ( file)
424+ /// Download a file from its remote, saving all snapshots to a database in the
425+ /// specified location. Returns a FileContext for opening the file later.
426+ ///
427+ /// * `path` - File path for saved database
428+ pub fn download_database ( & self , path : impl AsRef < Path > ) -> Result < Ref < FileMetadata > , ( ) > {
429+ //TODO: deprecated, use RemoteFile.download() and ProjectFile.export()
430+ self . download_database_with_progress ( path, NoProgressCallback )
430431 }
431432
432- // TODO: This might be a bad helper... maybe remove...
433- /// Download a remote file and save it to a BNDB at the given `path`.
433+ /// Download a remote file and save it to a BNDB at the given `path`, returning the associated [`FileMetadata`].
434+ /// Download a file from its remote, saving all snapshots to a database in the
435+ /// specified location. Returns a FileContext for opening the file later.
436+ ///
437+ /// * `path` - File path for saved database
438+ /// * `progress_function` - Function to call for progress updates
434439 pub fn download_database_with_progress (
435440 & self ,
436- path : & Path ,
441+ path : impl AsRef < Path > ,
437442 progress : impl ProgressCallback ,
438443 ) -> Result < Ref < FileMetadata > , ( ) > {
444+ //TODO: deprecated, use RemoteFile.download_with_progress() and ProjectFile.export()
439445 let mut progress = progress. split ( & [ 50 , 50 ] ) ;
440- let file = self . download_with_progress ( path, progress. next_subpart ( ) . unwrap ( ) ) ?;
446+ let file = sync:: download_file_with_progress (
447+ self ,
448+ path. as_ref ( ) ,
449+ progress. next_subpart ( ) . unwrap ( ) ,
450+ ) ?;
441451 let database = file. database ( ) . ok_or ( ( ) ) ?;
442452 self . sync_with_progress (
443453 & database,
0 commit comments