Skip to content

Commit 8021afb

Browse files
authored
Merge pull request #568 from AOSC-Dev/no-set-permission
No set permission
2 parents 4e0a5ee + 6d08586 commit 8021afb

File tree

5 files changed

+2
-68
lines changed

5 files changed

+2
-68
lines changed

oma-fetch/src/download.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use crate::{CompressFile, DownloadSource, Event, checksum::ChecksumValidator, send_request};
22
use std::{
33
borrow::Cow,
4-
fs::Permissions,
54
io::{self, SeekFrom},
6-
os::unix::fs::PermissionsExt,
75
path::Path,
86
time::Duration,
97
};
@@ -46,7 +44,6 @@ pub(crate) struct SingleDownloader<'a> {
4644
msg: Option<Cow<'static, str>>,
4745
download_list_index: usize,
4846
file_type: CompressFile,
49-
set_permission: Option<u32>,
5047
timeout: Duration,
5148
}
5249

@@ -106,7 +103,6 @@ impl<'a> SingleDownloader<'a> {
106103
msg: Option<Cow<'static, str>>,
107104
download_list_index: usize,
108105
file_type: CompressFile,
109-
set_permission: Option<u32>,
110106
timeout: Duration,
111107
) -> Result<SingleDownloader<'a>, BuilderError> {
112108
if entry.source.is_empty() {
@@ -123,7 +119,6 @@ impl<'a> SingleDownloader<'a> {
123119
msg,
124120
download_list_index,
125121
file_type,
126-
set_permission,
127122
timeout,
128123
})
129124
}
@@ -258,8 +253,6 @@ impl<'a> SingleDownloader<'a> {
258253
self.entry.filename
259254
);
260255

261-
self.set_permission_with_path(&file).await?;
262-
263256
if let Some(hash) = &self.entry.hash {
264257
trace!("Hash {} exists for the existing file.", hash);
265258

@@ -423,8 +416,6 @@ impl<'a> SingleDownloader<'a> {
423416
return Err(SingleDownloadError::Create { source: e });
424417
}
425418

426-
self.set_permission(&f).await?;
427-
428419
(f, hash.as_ref().map(|hash| hash.get_validator()))
429420
} else if let Some((dest, validator)) = dest.zip(validator) {
430421
callback(Event::ProgressInc {
@@ -459,8 +450,6 @@ impl<'a> SingleDownloader<'a> {
459450
return Err(SingleDownloadError::Create { source: e });
460451
}
461452

462-
self.set_permission(&f).await?;
463-
464453
(f, hash.as_ref().map(|hash| hash.get_validator()))
465454
};
466455

@@ -558,35 +547,6 @@ impl<'a> SingleDownloader<'a> {
558547
Ok(true)
559548
}
560549

561-
async fn set_permission(&self, f: &File) -> Result<(), SingleDownloadError> {
562-
if let Some(mode) = self.set_permission {
563-
trace!(
564-
"Setting permission for file {} to {:#o} ...",
565-
self.entry.filename, mode
566-
);
567-
f.set_permissions(Permissions::from_mode(mode))
568-
.await
569-
.context(SetPermissionSnafu)?;
570-
}
571-
572-
Ok(())
573-
}
574-
575-
async fn set_permission_with_path(&self, path: &Path) -> Result<(), SingleDownloadError> {
576-
if let Some(mode) = self.set_permission {
577-
trace!(
578-
"Setting permission for file {} to {:#o} ...",
579-
self.entry.filename, mode
580-
);
581-
582-
fs::set_permissions(path, Permissions::from_mode(mode))
583-
.await
584-
.context(SetPermissionSnafu)?;
585-
}
586-
587-
Ok(())
588-
}
589-
590550
fn build_request_with_basic_auth(
591551
&self,
592552
url: &str,
@@ -665,8 +625,6 @@ impl<'a> SingleDownloader<'a> {
665625
.await
666626
.context(CreateSnafu)?;
667627

668-
self.set_permission(&to).await?;
669-
670628
let reader: &mut (dyn AsyncRead + Unpin + Send) = match self.file_type {
671629
CompressFile::Xz => &mut XzDecoder::new(BufReader::new(from)),
672630
CompressFile::Gzip => &mut GzipDecoder::new(BufReader::new(from)),

oma-fetch/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ pub struct DownloadManager<'a> {
194194
retry_times: usize,
195195
#[builder(default)]
196196
total_size: u64,
197-
set_permission: Option<u32>,
198197
#[builder(default = Duration::from_secs(15))]
199198
timeout: Duration,
200199
}
@@ -239,7 +238,6 @@ impl DownloadManager<'_> {
239238
.progress((i + 1, self.download_list.len()))
240239
.retry_times(self.retry_times)
241240
.file_type(c.file_type)
242-
.maybe_set_permission(self.set_permission)
243241
.timeout(self.timeout)
244242
.build()?;
245243

oma-pm/src/commit.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{borrow::Cow, fs::create_dir_all, os::unix::fs::PermissionsExt, path::Path};
1+
use std::{borrow::Cow, fs::create_dir_all, path::Path};
22

33
use apt_auth_config::AuthConfig;
44
use chrono::Local;
@@ -79,9 +79,6 @@ impl<'a> DoInstall<'a> {
7979
create_dir_all(path)
8080
.map_err(|e| OmaAptError::FailedOperateDirOrFile(path.display().to_string(), e))?;
8181

82-
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755))
83-
.map_err(|e| OmaAptError::FailedOperateDirOrFile(path.display().to_string(), e))?;
84-
8582
self.apt.get_or_init_async_runtime()?.block_on(async {
8683
if let Some(conn) = self.apt.conn.get() {
8784
change_status(conn, "Downloading").await.ok();

oma-refresh/src/db.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{
22
borrow::Cow,
3-
fs::Permissions,
4-
os::{fd::OwnedFd, unix::fs::PermissionsExt},
3+
os::fd::OwnedFd,
54
path::{Path, PathBuf},
65
};
76

@@ -259,17 +258,6 @@ impl<'a> OmaRefresh<'a> {
259258
})?;
260259
}
261260

262-
debug!(
263-
"Setting permission for {} as 0755",
264-
self.download_dir.display()
265-
);
266-
267-
fs::set_permissions(&self.download_dir, Permissions::from_mode(0o755))
268-
.await
269-
.map_err(|e| {
270-
RefreshError::FailedToOperateDirOrFile(self.download_dir.display().to_string(), e)
271-
})?;
272-
273261
let download_dir: Box<Path> = Box::from(self.download_dir.as_path());
274262

275263
let _fd = spawn_blocking(move || get_apt_update_lock(&download_dir))
@@ -344,7 +332,6 @@ impl<'a> OmaRefresh<'a> {
344332
.client(self.client)
345333
.download_list(tasks)
346334
.threads(self.threads)
347-
.set_permission(0o644)
348335
.total_size(total)
349336
.build();
350337

oma-refresh/src/sourceslist.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::{
22
borrow::Cow,
33
fmt::Debug,
4-
fs::Permissions,
5-
os::unix::fs::PermissionsExt,
64
path::{Path, PathBuf},
75
};
86

@@ -513,10 +511,6 @@ impl MirrorSource<'_> {
513511
.await
514512
.map_err(|e| SingleDownloadError::Create { source: e })?;
515513

516-
f.set_permissions(Permissions::from_mode(0o644))
517-
.await
518-
.map_err(|e| SingleDownloadError::SetPermission { source: e })?;
519-
520514
while let Some(chunk) = resp
521515
.chunk()
522516
.await

0 commit comments

Comments
 (0)