Skip to content

Commit

Permalink
ignore windows platform for releasing and compilation because the com…
Browse files Browse the repository at this point in the history
…pilation failed on unrar.
  • Loading branch information
tamada committed May 1, 2024
1 parent 2565a24 commit 6523f0e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- windows-latest
# - windows-latest
- macos-latest
steps:
- name: Setup Rust
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ jobs:
# target: aarch64-pc-windows-gnullvm
# artifact_name: ${{ needs.setup.outputs.appname }}.exe
# asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_amd64
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
artifact_name: ${{ needs.setup.outputs.appname }}.exe
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_arm64
# - os: ubuntu-latest
# target: x86_64-pc-windows-gnu
# artifact_name: ${{ needs.setup.outputs.appname }}.exe
# asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_arm64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: ${{ needs.setup.outputs.appname }}
Expand Down
1 change: 1 addition & 0 deletions src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::archiver::tar::{TarArchiver, TarGzArchiver, TarBz2Archiver};
use crate::verboser::{create_verboser, Verboser};
use crate::CliOpts;

mod optscreator;
mod zip;
mod rar;
mod tar;
Expand Down
6 changes: 6 additions & 0 deletions src/archiver/optscreator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[cfg(target_os = "windows")]
pub mod windows;

#[cfg(any(target_os = "linux", target_os = "macos"))]
pub mod linux;

17 changes: 17 additions & 0 deletions src/archiver/optscreator/linux.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;

use time::OffsetDateTime;
use zip::write::SimpleFileOptions;
use zip::DateTime;

pub fn create(target: &PathBuf) -> SimpleFileOptions {
let metadata = std::fs::metadata(&target).unwrap();
let mod_time = DateTime::try_from(
OffsetDateTime::from(metadata.modified().unwrap()));

SimpleFileOptions::default()
.last_modified_time(mod_time.unwrap())
.compression_method(zip::CompressionMethod::Stored)
.unix_permissions(metadata.permissions().mode())
}
9 changes: 9 additions & 0 deletions src/archiver/optscreator/windows.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub fn create(target: &PathBuf) -> SimpleFileOptions {
let metadata = std::fs::metadata(&target).unwrap();
let mod_time = DateTime::try_from(
OffsetDateTime::from(metadata.modified().unwrap()));

SimpleFileOptions::default()
.last_modified_time(mod_time.unwrap())
.compression_method(zip::CompressionMethod::Stored)
}
22 changes: 10 additions & 12 deletions src/archiver/zip.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
#[cfg(target_os = "windows")]
use optscreator::windows::*;

#[cfg(any(target_os = "linux", target_os = "macos"))]
use optscreator::linux::*;

use std::fs::File;
use std::path::PathBuf;
use std::io::{BufReader, Write, Seek};
use time::OffsetDateTime;
use zip::write::SimpleFileOptions;
use zip::{ZipWriter, DateTime};
use zip::ZipWriter;

use crate::archiver::{Archiver, Format, ArchiverOpts};
use crate::archiver::optscreator;
use crate::cli::{ToatError, Result};

pub(super) struct ZipArchiver {
Expand Down Expand Up @@ -43,13 +47,7 @@ fn process_dir<W:Write+Seek> (zw: &mut ZipWriter<W>, target: PathBuf) -> Result<

fn process_file<W:Write+Seek> (zw: &mut ZipWriter<W>, target: PathBuf) -> Result<()> {
let name = target.to_str().unwrap();
let metadata = std::fs::metadata(&target).unwrap();
let mod_time = DateTime::try_from(
OffsetDateTime::from(metadata.modified().unwrap()));
let opts = SimpleFileOptions::default()
.last_modified_time(mod_time.unwrap())
.compression_method(zip::CompressionMethod::Stored)
.unix_permissions(metadata.permissions().mode());
let opts = create(&target);
if let Err(e) = zw.start_file(name, opts) {
return Err(ToatError::ArchiverError(e.to_string()));
}
Expand Down

0 comments on commit 6523f0e

Please sign in to comment.