guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/109: gnu: rust-trash-2: Update to 2.1.5.


From: guix-commits
Subject: 02/109: gnu: rust-trash-2: Update to 2.1.5.
Date: Wed, 27 Dec 2023 10:10:37 -0500 (EST)

efraim pushed a commit to branch rust-team
in repository guix.

commit f09ac2c21a0326b79ab4ea6fb24d760e91b5096c
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Wed Dec 27 08:19:59 2023 +0200

    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
---
 gnu/local.mk                                       |   1 +
 gnu/packages/crates-io.scm                         |   7 +-
 .../patches/rust-trash-2-update-windows.patch      | 132 +++++++++++++++++++++
 3 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index bf6c6aebb8..d6d556248d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1975,6 +1975,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                    \
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 73904e4ac1..ddcf9ff146 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -85300,14 +85300,15 @@ be used directly.  See @code{rust-trackable} for more 
information.")
 (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
@@ -85318,7 +85319,7 @@ be used directly.  See @code{rust-trackable} for more 
information.")
         ("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)
diff --git a/gnu/packages/patches/rust-trash-2-update-windows.patch 
b/gnu/packages/patches/rust-trash-2-update-windows.patch
new file mode 100644
index 0000000000..f6b13a4658
--- /dev/null
+++ b/gnu/packages/patches/rust-trash-2-update-windows.patch
@@ -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);
+         }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]