diff options
Diffstat (limited to 'crates/shirabe/src/downloader')
| -rw-r--r-- | crates/shirabe/src/downloader/archive_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/download_manager.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/file_downloader.rs | 8 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/fossil_downloader.rs | 7 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/git_downloader.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/gzip_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/hg_downloader.rs | 7 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/path_downloader.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/perforce_downloader.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/phar_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/rar_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/svn_downloader.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/tar_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/vcs_downloader.rs | 14 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/xz_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/zip_downloader.rs | 4 |
16 files changed, 49 insertions, 34 deletions
diff --git a/crates/shirabe/src/downloader/archive_downloader.rs b/crates/shirabe/src/downloader/archive_downloader.rs index 6c8a8f9..ffa2ef4 100644 --- a/crates/shirabe/src/downloader/archive_downloader.rs +++ b/crates/shirabe/src/downloader/archive_downloader.rs @@ -11,6 +11,8 @@ use shirabe_php_shim::{ use crate::dependency_resolver::operation::InstallOperation; use crate::downloader::DownloaderInterface; use crate::downloader::FileDownloader; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::util::Filesystem; use crate::util::Platform; diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index f5201cc..83a03c4 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -13,6 +13,7 @@ use shirabe_php_shim::{ use crate::downloader::DownloaderInterface; use crate::exception::IrrecoverableDownloadException; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::util::Filesystem; @@ -20,7 +21,7 @@ use crate::util::Filesystem; #[derive(Debug)] pub struct DownloadManager { /// @var IOInterface - pub(crate) io: Box<dyn IOInterface>, + pub(crate) io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, /// @var bool prefer_dist: bool, /// @var bool @@ -40,7 +41,7 @@ impl DownloadManager { /// @param bool $preferSource prefer downloading from source /// @param Filesystem|null $filesystem custom Filesystem object pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, prefer_source: bool, filesystem: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, ) -> Self { diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index dc8c5a5..4f2ee63 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -25,6 +25,8 @@ use crate::downloader::TransportException; use crate::event_dispatcher::EventDispatcher; use crate::exception::IrrecoverableDownloadException; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::io::IOInterfaceMutable; use crate::io::NullIO; use crate::package::PackageInterface; use crate::package::comparer::Comparer; @@ -55,7 +57,7 @@ pub static RESPONSE_HEADERS: LazyLock<Mutex<IndexMap<String, Vec<String>>>> = #[derive(Debug)] pub struct FileDownloader { /// @var IOInterface - pub(crate) io: Box<dyn IOInterface>, + pub(crate) io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, /// @var Config pub(crate) config: std::rc::Rc<std::cell::RefCell<Config>>, /// @var HttpDownloader @@ -92,7 +94,7 @@ impl FileDownloader { /// Constructor. pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, @@ -102,7 +104,7 @@ impl FileDownloader { ) -> Self { let process = process.unwrap_or_else(|| { std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( - io.clone_box(), + io.clone(), )))) }); let filesystem = filesystem.unwrap_or_else(|| { diff --git a/crates/shirabe/src/downloader/fossil_downloader.rs b/crates/shirabe/src/downloader/fossil_downloader.rs index 1e164b8..9f0277e 100644 --- a/crates/shirabe/src/downloader/fossil_downloader.rs +++ b/crates/shirabe/src/downloader/fossil_downloader.rs @@ -4,6 +4,7 @@ use crate::config::Config; use crate::downloader::DownloaderInterface; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::util::Filesystem; use crate::util::ProcessExecutor; @@ -18,7 +19,7 @@ pub struct FossilDownloader { impl FossilDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, fs: std::rc::Rc<std::cell::RefCell<Filesystem>>, @@ -46,7 +47,7 @@ impl FossilDownloader { ) -> Result<Option<PhpMixed>> { self.inner.config.borrow_mut().prohibit_url_by_config( &url, - Some(self.inner.io.as_ref()), + Some(&*self.inner.io.borrow()), &indexmap::IndexMap::new(), )?; @@ -107,7 +108,7 @@ impl FossilDownloader { ) -> Result<Option<PhpMixed>> { self.inner.config.borrow_mut().prohibit_url_by_config( &url, - Some(self.inner.io.as_ref()), + Some(&*self.inner.io.borrow()), &indexmap::IndexMap::new(), )?; diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index a5e3638..b3e00a2 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -14,6 +14,7 @@ use crate::config::Config; use crate::downloader::DvcsDownloaderInterface; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::util::Filesystem; use crate::util::Git as GitUtil; @@ -35,14 +36,14 @@ pub struct GitDownloader { impl GitDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, process: Option<std::rc::Rc<std::cell::RefCell<ProcessExecutor>>>, fs: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, ) -> Self { let inner = VcsDownloaderBase::new(io, config, process, fs); let git_util = GitUtil::new( - inner.io.clone_box(), + inner.io.clone(), inner.config.clone(), inner.process.clone(), inner.filesystem.clone(), diff --git a/crates/shirabe/src/downloader/gzip_downloader.rs b/crates/shirabe/src/downloader/gzip_downloader.rs index fe44fed..55dff10 100644 --- a/crates/shirabe/src/downloader/gzip_downloader.rs +++ b/crates/shirabe/src/downloader/gzip_downloader.rs @@ -27,7 +27,7 @@ pub struct GzipDownloader { impl GzipDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, diff --git a/crates/shirabe/src/downloader/hg_downloader.rs b/crates/shirabe/src/downloader/hg_downloader.rs index b12e348..d4c53f3 100644 --- a/crates/shirabe/src/downloader/hg_downloader.rs +++ b/crates/shirabe/src/downloader/hg_downloader.rs @@ -4,6 +4,7 @@ use crate::config::Config; use crate::downloader::DownloaderInterface; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::util::Filesystem; use crate::util::Hg as HgUtils; @@ -18,7 +19,7 @@ pub struct HgDownloader { impl HgDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, fs: std::rc::Rc<std::cell::RefCell<Filesystem>>, @@ -53,7 +54,7 @@ impl HgDownloader { url: String, ) -> Result<Option<PhpMixed>> { let hg_utils = HgUtils::new( - &*self.inner.io, + self.inner.io.clone(), &*self.inner.config.borrow(), &self.inner.process, ); @@ -108,7 +109,7 @@ impl HgDownloader { url: String, ) -> Result<Option<PhpMixed>> { let hg_utils = HgUtils::new( - &*self.inner.io, + self.inner.io.clone(), &*self.inner.config.borrow(), &self.inner.process, ); diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 46090ac..44541d4 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -19,6 +19,7 @@ use crate::downloader::FileDownloader; use crate::downloader::VcsCapableDownloaderInterface; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::package::archiver::ArchivableFilesFinder; use crate::package::dumper::ArrayDumper; @@ -39,7 +40,7 @@ impl PathDownloader { const STRATEGY_MIRROR: i64 = 20; pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, @@ -391,7 +392,7 @@ impl PathDownloader { self.inner.config.clone(), self.inner.process.clone(), parser.clone(), - Some(self.inner.io.clone_box()), + Some(self.inner.io.clone()), ); let dumper = ArrayDumper::new(); diff --git a/crates/shirabe/src/downloader/perforce_downloader.rs b/crates/shirabe/src/downloader/perforce_downloader.rs index b3f7bc9..f967111 100644 --- a/crates/shirabe/src/downloader/perforce_downloader.rs +++ b/crates/shirabe/src/downloader/perforce_downloader.rs @@ -4,6 +4,7 @@ use crate::config::Config; use crate::downloader::DownloaderInterface; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::repository::VcsRepository; use crate::util::Filesystem; @@ -22,7 +23,7 @@ pub struct PerforceDownloader { impl PerforceDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, fs: std::rc::Rc<std::cell::RefCell<Filesystem>>, @@ -103,7 +104,7 @@ impl PerforceDownloader { url, path, self.inner.process.clone(), - self.inner.io.clone_box(), + self.inner.io.clone(), )); } diff --git a/crates/shirabe/src/downloader/phar_downloader.rs b/crates/shirabe/src/downloader/phar_downloader.rs index a598437..235e0bb 100644 --- a/crates/shirabe/src/downloader/phar_downloader.rs +++ b/crates/shirabe/src/downloader/phar_downloader.rs @@ -23,7 +23,7 @@ pub struct PharDownloader { impl PharDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, diff --git a/crates/shirabe/src/downloader/rar_downloader.rs b/crates/shirabe/src/downloader/rar_downloader.rs index f482582..bb0c2f8 100644 --- a/crates/shirabe/src/downloader/rar_downloader.rs +++ b/crates/shirabe/src/downloader/rar_downloader.rs @@ -26,7 +26,7 @@ pub struct RarDownloader { impl RarDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index 162e91c..f3683dd 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -9,6 +9,7 @@ use crate::config::Config; use crate::downloader::DownloaderInterface; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::repository::VcsRepository; use crate::util::Filesystem; @@ -23,7 +24,7 @@ pub struct SvnDownloader { impl SvnDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, fs: std::rc::Rc<std::cell::RefCell<Filesystem>>, @@ -44,7 +45,7 @@ impl SvnDownloader { SvnUtil::clean_env(); let mut util = SvnUtil::new( url.to_string(), - self.inner.io.clone_box(), + self.inner.io.clone(), self.inner.config.clone(), Some(self.inner.process.clone()), ); @@ -126,7 +127,7 @@ impl SvnDownloader { let mut util = SvnUtil::new( url.to_string(), - self.inner.io.clone_box(), + self.inner.io.clone(), self.inner.config.clone(), Some(self.inner.process.clone()), ); @@ -186,7 +187,7 @@ impl SvnDownloader { ) -> anyhow::Result<String> { let mut util = SvnUtil::new( base_url.to_string(), - self.inner.io.clone_box(), + self.inner.io.clone(), self.inner.config.clone(), Some(self.inner.process.clone()), ); @@ -381,7 +382,7 @@ impl SvnDownloader { let mut util = SvnUtil::new( base_url, - self.inner.io.clone_box(), + self.inner.io.clone(), self.inner.config.clone(), Some(self.inner.process.clone()), ); diff --git a/crates/shirabe/src/downloader/tar_downloader.rs b/crates/shirabe/src/downloader/tar_downloader.rs index 09b6f5a..7314ecd 100644 --- a/crates/shirabe/src/downloader/tar_downloader.rs +++ b/crates/shirabe/src/downloader/tar_downloader.rs @@ -23,7 +23,7 @@ pub struct TarDownloader { impl TarDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs index 096e93d..736d433 100644 --- a/crates/shirabe/src/downloader/vcs_downloader.rs +++ b/crates/shirabe/src/downloader/vcs_downloader.rs @@ -17,6 +17,7 @@ use crate::downloader::ChangeReportInterface; use crate::downloader::DownloaderInterface; use crate::downloader::VcsCapableDownloaderInterface; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::package::dumper::ArrayDumper; use crate::package::version::VersionGuesser; @@ -26,7 +27,7 @@ use crate::util::ProcessExecutor; #[derive(Debug)] pub struct VcsDownloaderBase { - pub io: Box<dyn IOInterface>, + pub io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, pub config: std::rc::Rc<std::cell::RefCell<Config>>, pub process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, pub filesystem: std::rc::Rc<std::cell::RefCell<Filesystem>>, @@ -35,13 +36,14 @@ pub struct VcsDownloaderBase { impl VcsDownloaderBase { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, process: Option<std::rc::Rc<std::cell::RefCell<ProcessExecutor>>>, fs: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, ) -> Self { - let process = process - .unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(())))); + let process = process.unwrap_or_else(|| { + std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))) + }); let filesystem = fs.unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None)))); Self { @@ -72,7 +74,7 @@ impl VcsDownloaderBase { pub trait VcsDownloader: DownloaderInterface + ChangeReportInterface + VcsCapableDownloaderInterface { - fn io(&self) -> &dyn IOInterface; + fn io(&self) -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>>; fn io_mut(&mut self) -> &mut dyn IOInterface; fn config(&self) -> &std::rc::Rc<std::cell::RefCell<Config>>; fn config_mut(&mut self) -> &mut std::rc::Rc<std::cell::RefCell<Config>>; @@ -442,7 +444,7 @@ pub trait VcsDownloader: self.config().clone(), self.process().clone(), parser.clone(), - Some(self.io().clone_box()), + Some(self.io().clone()), ); let dumper = ArrayDumper::new(); diff --git a/crates/shirabe/src/downloader/xz_downloader.rs b/crates/shirabe/src/downloader/xz_downloader.rs index ca867df..fd83b28 100644 --- a/crates/shirabe/src/downloader/xz_downloader.rs +++ b/crates/shirabe/src/downloader/xz_downloader.rs @@ -22,7 +22,7 @@ pub struct XzDownloader { impl XzDownloader { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: std::rc::Rc<std::cell::RefCell<Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, event_dispatcher: Option<std::rc::Rc<std::cell::RefCell<EventDispatcher>>>, diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs index eb057e0..4c72b91 100644 --- a/crates/shirabe/src/downloader/zip_downloader.rs +++ b/crates/shirabe/src/downloader/zip_downloader.rs @@ -3,6 +3,8 @@ use crate::downloader::ArchiveDownloader; use crate::downloader::DownloaderInterface; use crate::downloader::FileDownloader; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::util::IniHelper; use crate::util::Platform; @@ -33,7 +35,7 @@ pub struct ZipDownloader { impl ZipDownloader { pub fn new( - io: Box<dyn crate::io::IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn crate::io::IOInterface>>, config: std::rc::Rc<std::cell::RefCell<crate::config::Config>>, http_downloader: std::rc::Rc<std::cell::RefCell<crate::util::HttpDownloader>>, event_dispatcher: Option< |
