mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 22:08:16 -05:00
gnu: rust-trash-2: Update to 2.1.5.
* gnu/packages/crates-io.scm (rust-trash-2): Update to 2.1.5. [source]: Add patch. [cargo-inputs]: Replace rust-windows-0.9 with 0.44. * gnu/packages/patches/rust-trash-2-update-windows.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Change-Id: I707b2139800d37f3609958251893e5948e40cd34
This commit is contained in:
parent
8e90017c65
commit
8f99a3e604
3 changed files with 137 additions and 3 deletions
|
@ -2008,6 +2008,7 @@ dist_patch_DATA = \
|
|||
%D%/packages/patches/rust-ndarray-0.13-remove-blas-src.patch \
|
||||
%D%/packages/patches/rust-ndarray-0.14-remove-blas-src.patch \
|
||||
%D%/packages/patches/rust-nettle-disable-vendor.patch \
|
||||
%D%/packages/patches/rust-trash-2-update-windows.patch \
|
||||
%D%/packages/patches/rust-webbrowser-remove-unsupported-os.patch \
|
||||
%D%/packages/patches/rust-wl-clipboard-rs-newer-wl.patch \
|
||||
%D%/packages/patches/rw-igraph-0.10.patch \
|
||||
|
|
|
@ -85416,14 +85416,15 @@ (define-public rust-traitobject-0.1
|
|||
(define-public rust-trash-2
|
||||
(package
|
||||
(name "rust-trash")
|
||||
(version "2.1.3")
|
||||
(version "2.1.5")
|
||||
(source
|
||||
(origin
|
||||
(method url-fetch)
|
||||
(uri (crate-uri "trash" version))
|
||||
(file-name (string-append name "-" version ".tar.gz"))
|
||||
(sha256
|
||||
(base32 "14ji8b84ghwkln01v90ahhl2jkxv2qxkm0afprzphf1ln41k6nqi"))))
|
||||
(base32 "0djjjvvpxhx4li3y0jp1q48xabvazzif8g7z6110rm4chikh62gy"))
|
||||
(patches (search-patches "rust-trash-2-update-windows.patch"))))
|
||||
(build-system cargo-build-system)
|
||||
(arguments
|
||||
`(#:cargo-inputs
|
||||
|
@ -85434,7 +85435,7 @@ (define-public rust-trash-2
|
|||
("rust-once-cell" ,rust-once-cell-1)
|
||||
("rust-scopeguard" ,rust-scopeguard-1)
|
||||
("rust-url" ,rust-url-2)
|
||||
("rust-windows" ,rust-windows-0.9))
|
||||
("rust-windows" ,rust-windows-0.44))
|
||||
#:cargo-development-inputs
|
||||
(("rust-chrono" ,rust-chrono-0.4)
|
||||
("rust-env-logger" ,rust-env-logger-0.9)
|
||||
|
|
132
gnu/packages/patches/rust-trash-2-update-windows.patch
Normal file
132
gnu/packages/patches/rust-trash-2-update-windows.patch
Normal file
|
@ -0,0 +1,132 @@
|
|||
This patch is taken from upstream so we can use an already packaged
|
||||
version of the windows crate.
|
||||
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index 2c28dfe..6b61771 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -87,9 +87,8 @@ version = "0.2.7"
|
||||
version = "1.0.0"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
-version = "0.37.0"
|
||||
+version = "0.44.0"
|
||||
features = [
|
||||
- "alloc",
|
||||
"Win32_Foundation",
|
||||
"Win32_System_Com_StructuredStorage",
|
||||
"Win32_UI_Shell_PropertiesSystem",
|
||||
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
|
||||
index 894a78c..c17fc02 100644
|
||||
--- a/Cargo.toml.orig
|
||||
+++ b/Cargo.toml.orig
|
||||
@@ -44,7 +44,7 @@ once_cell = "1.7.2"
|
||||
once_cell = "1.7.2"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
-windows = { version = "0.37.0", features = [ "alloc",
|
||||
+windows = { version = "0.44.0", features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_System_Com_StructuredStorage",
|
||||
"Win32_UI_Shell_PropertiesSystem",
|
||||
diff --git a/src/windows.rs b/src/windows.rs
|
||||
index c1379d3..3f4426b 100644
|
||||
--- a/src/windows.rs
|
||||
+++ b/src/windows.rs
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::{Error, TrashContext, TrashItem};
|
||||
use std::{
|
||||
- ffi::{OsStr, OsString},
|
||||
- mem::MaybeUninit,
|
||||
+ ffi::{c_void, OsStr, OsString},
|
||||
os::windows::{ffi::OsStrExt, prelude::*},
|
||||
path::PathBuf,
|
||||
};
|
||||
@@ -66,7 +65,7 @@ impl TrashContext {
|
||||
let shi: IShellItem =
|
||||
SHCreateItemFromParsingName(PCWSTR(wide_path_slice.as_ptr()), None)?;
|
||||
|
||||
- pfo.DeleteItem(shi, None)?;
|
||||
+ pfo.DeleteItem(&shi, None)?;
|
||||
}
|
||||
pfo.PerformOperations()?;
|
||||
Ok(())
|
||||
@@ -78,28 +77,18 @@ pub fn list() -> Result<Vec<TrashItem>, Error> {
|
||||
ensure_com_initialized();
|
||||
unsafe {
|
||||
let mut item_vec = Vec::new();
|
||||
- let mut recycle_bin = MaybeUninit::<Option<IShellItem>>::uninit();
|
||||
|
||||
- SHGetKnownFolderItem(
|
||||
- &FOLDERID_RecycleBinFolder,
|
||||
- KF_FLAG_DEFAULT,
|
||||
- HANDLE::default(),
|
||||
- &IShellItem::IID,
|
||||
- recycle_bin.as_mut_ptr() as _,
|
||||
- )?;
|
||||
-
|
||||
- let recycle_bin = recycle_bin.assume_init().ok_or(Error::Unknown {
|
||||
- description: "SHGetKnownFolderItem gave NULL for FOLDERID_RecycleBinFolder".into(),
|
||||
- })?;
|
||||
+ let recycle_bin: IShellItem =
|
||||
+ SHGetKnownFolderItem(&FOLDERID_RecycleBinFolder, KF_FLAG_DEFAULT, HANDLE::default())?;
|
||||
|
||||
let pesi: IEnumShellItems = recycle_bin.BindToHandler(None, &BHID_EnumItems)?;
|
||||
- let mut fetched: u32 = 0;
|
||||
|
||||
loop {
|
||||
+ let mut fetched_count: u32 = 0;
|
||||
let mut arr = [None];
|
||||
- pesi.Next(&mut arr, &mut fetched)?;
|
||||
+ pesi.Next(&mut arr, Some(&mut fetched_count as *mut u32))?;
|
||||
|
||||
- if fetched == 0 {
|
||||
+ if fetched_count == 0 {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -145,7 +134,7 @@ where
|
||||
at_least_one = true;
|
||||
let id_as_wide: Vec<u16> = item.id.encode_wide().chain(std::iter::once(0)).collect();
|
||||
let parsing_name = PCWSTR(id_as_wide.as_ptr());
|
||||
- let trash_item: IShellItem = SHCreateItemFromParsingName(&parsing_name, None)?;
|
||||
+ let trash_item: IShellItem = SHCreateItemFromParsingName(parsing_name, None)?;
|
||||
pfo.DeleteItem(&trash_item, None)?;
|
||||
}
|
||||
if at_least_one {
|
||||
@@ -181,7 +170,7 @@ where
|
||||
for item in items.iter() {
|
||||
let id_as_wide: Vec<u16> = item.id.encode_wide().chain(std::iter::once(0)).collect();
|
||||
let parsing_name = PCWSTR(id_as_wide.as_ptr());
|
||||
- let trash_item: IShellItem = SHCreateItemFromParsingName(&parsing_name, None)?;
|
||||
+ let trash_item: IShellItem = SHCreateItemFromParsingName(parsing_name, None)?;
|
||||
let parent_path_wide: Vec<_> =
|
||||
item.original_parent.as_os_str().encode_wide().chain(std::iter::once(0)).collect();
|
||||
let orig_folder_shi: IShellItem =
|
||||
@@ -191,7 +180,7 @@ where
|
||||
.chain(std::iter::once(0))
|
||||
.collect();
|
||||
|
||||
- pfo.MoveItem(trash_item, orig_folder_shi, PCWSTR(name_wstr.as_ptr()), None)?;
|
||||
+ pfo.MoveItem(&trash_item, &orig_folder_shi, PCWSTR(name_wstr.as_ptr()), None)?;
|
||||
}
|
||||
if !items.is_empty() {
|
||||
pfo.PerformOperations()?;
|
||||
@@ -203,7 +192,7 @@ where
|
||||
unsafe fn get_display_name(psi: &IShellItem, sigdnname: SIGDN) -> Result<OsString, Error> {
|
||||
let name = psi.GetDisplayName(sigdnname)?;
|
||||
let result = wstr_to_os_string(name);
|
||||
- CoTaskMemFree(name.0 as _);
|
||||
+ CoTaskMemFree(Some(name.0 as *const c_void));
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
@@ -257,7 +246,7 @@ impl CoInitializer {
|
||||
if cfg!(feature = "coinit_speed_over_memory") {
|
||||
init_mode |= COINIT_SPEED_OVER_MEMORY;
|
||||
}
|
||||
- let hr = unsafe { CoInitializeEx(std::ptr::null_mut(), init_mode) };
|
||||
+ let hr = unsafe { CoInitializeEx(None, init_mode) };
|
||||
if hr.is_err() {
|
||||
panic!("Call to CoInitializeEx failed. HRESULT: {:?}. Consider using `trash` with the feature `coinit_multithreaded`", hr);
|
||||
}
|
Loading…
Reference in a new issue