trash_lib 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a95f6070a2a39e218dff3d06852dbb0f784bf613d5648a616bc39e7104892a74
4
- data.tar.gz: 7542becd9922251f1bc6fb42079ad5296d1e9af5b611c07816fbe7de338217cc
3
+ metadata.gz: a6e39776a6ccc6111fb404ecc529058d92896221e9c806357978e092969cff85
4
+ data.tar.gz: 7cef4b83bcd07f86ebb5c0ce34dc58941210700a975ae4e22a679c90ef184879
5
5
  SHA512:
6
- metadata.gz: a54b265683be7bf27b888a3853188cb49b48fc470cea83fe5497aa0091b396640356fe534aec999733565bb01e0aab44304e3f52c1732c11a21fa511b840858f
7
- data.tar.gz: 825344d5b5c066b83af8bbc7762e0c46a143d0905053f5b77abe5fdc88d393e0e241f2c6e26511b9c6f92f2cda4390e18932f1920b956a84a7e81af19da03009
6
+ metadata.gz: 14b5aac37a5841ab9a930cf59d1d55cd9e2e0335bc785bbcf3709059ac9ba694ad50cf9e6b0666ecd400e2f270ad2664ec9789be6725fef2a716660ec65562d2
7
+ data.tar.gz: e554d14771f0e76b5eae1a366efa947d5ffcca70954bf89f5f92ce7e735844931a66a928ad1780d2f6e57f98ffdf2d2cdf5dfd3ed4112b4f25bddac904e790ad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.2] - 2023-08-16
2
+
3
+ - Hot fixed `Trash::Entry#restore` and `Trash::Entry#delete`.
4
+
1
5
  ## [1.0.1] - 2023-08-16
2
6
 
3
7
  - Hot fixed `Trash::put`.
data/lib/trash/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trash
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
data/lib/trash.rb CHANGED
@@ -25,7 +25,7 @@ module Trash
25
25
 
26
26
  # Restore file to original path.
27
27
  def restore
28
- FileUtils.move(path, origin, secure: true) # FIXME
28
+ FileUtils.move(trash_path, origin, secure: true)
29
29
  delete_info
30
30
 
31
31
  nil
@@ -33,7 +33,7 @@ module Trash
33
33
 
34
34
  # Permanently delete the file.
35
35
  def delete
36
- FileUtils.remove_entry_secure(path, force: true)
36
+ FileUtils.rm_rf(trash_path, secure: true)
37
37
  delete_info
38
38
 
39
39
  nil
@@ -41,6 +41,10 @@ module Trash
41
41
 
42
42
  private
43
43
 
44
+ def trash_path
45
+ File.join(TRASH_FILE_PATH, path)
46
+ end
47
+
44
48
  def info
45
49
  File.file?(info_path) ? File.read(info_path) : ''
46
50
  end
@@ -50,7 +54,7 @@ module Trash
50
54
  end
51
55
 
52
56
  def delete_info
53
- FileUtils.remove_entry_secure(info_path, force: true)
57
+ FileUtils.rm_rf(info_path, secure: true)
54
58
  end
55
59
  end
56
60
 
@@ -75,18 +79,17 @@ module Trash
75
79
  FileUtils.move(path, trash_path, secure: true)
76
80
  make_trash_info(path, trash_name)
77
81
 
78
- Entry.new trash_path
82
+ Dir.chdir TRASH_FILE_PATH do
83
+ Entry.new(File.basename(trash_path))
84
+ end
79
85
  end
80
86
  end
81
87
 
82
88
  # Empty the trash.
83
89
  def empty
90
+ FileUtils.rm_rf([TRASH_FILE_PATH, TRASH_INFO_PATH], secure: true)
84
91
  make_trash_paths
85
92
 
86
- [TRASH_FILE_PATH, TRASH_INFO_PATH]
87
- .map { Dir.children _1 }.flatten
88
- .each { FileUtils.remove_entry_secure _1, force: true }
89
-
90
93
  nil
91
94
  end
92
95
 
@@ -109,13 +112,14 @@ module Trash
109
112
  end
110
113
 
111
114
  def make_trash_info(path, trash_name)
112
- File.open(File.join(TRASH_INFO_PATH, "#{trash_name}.trashinfo"), 'w') do |file|
113
- file.write <<~TRASH_INFO
115
+ File.write(
116
+ File.join(TRASH_INFO_PATH, "#{trash_name}.trashinfo"),
117
+ <<~TRASH_INFO
114
118
  [Trash Info]
115
119
  Path=#{File.absolute_path path}
116
120
  DeletionDate=#{Time.now.strftime '%Y-%m-%dT%T'}
117
121
  TRASH_INFO
118
- end
122
+ )
119
123
  end
120
124
  end
121
125
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trash_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - NNB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-15 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a library for system file's trash in FreeDesktop Trash compliant
14
14
  environments.