[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/9] dtas-tl: drop encoding hacks, use binary stdout+stderr
From: |
Eric Wong |
Subject: |
[PATCH 5/9] dtas-tl: drop encoding hacks, use binary stdout+stderr |
Date: |
Sun, 23 Jan 2022 21:37:42 +0000 |
Try to consistently treat pathnames as binary blobs everywhere,
since POSIX FSes allow everything but "\0" in pathnames.
---
bin/dtas-tl | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/bin/dtas-tl b/bin/dtas-tl
index 767b02d..e58ee31 100755
--- a/bin/dtas-tl
+++ b/bin/dtas-tl
@@ -7,6 +7,8 @@
# itself is also unstable, but better than this one probably).
require 'dtas/unix_client'
require 'shellwords'
+$stdout.binmode
+$stderr.binmode
def get_track_ids(c)
track_ids = c.req("tl tracks")
@@ -16,18 +18,11 @@ def get_track_ids(c)
track_ids
end
-def fix_enc!(str, enc)
- str.force_encoding(enc)
- str.force_encoding(Encoding::ASCII_8BIT) unless str.valid_encoding?
-end
-
def each_track(c)
- enc = Encoding.default_external
get_track_ids(c).each_slice(128) do |track_ids|
res = c.req("tl get #{track_ids.join(' ')}")
res = Shellwords.split(res.sub!(/\A\d+ /, ''))
while line = res.shift
- fix_enc!(line, enc)
yield line
end
end
@@ -109,7 +104,6 @@ def do_edit(c)
path = File.expand_path(path)
unless File.exist?(path)
path = orig.dup
- fix_enc!(path, enc)
path = Shellwords.split(path)[0]
path = File.expand_path(path)
end
- [PATCH 0/9] various cuts for memory savings, Eric Wong, 2022/01/23
- [PATCH 1/9] deduplicate and freeze pathnames + metadata, Eric Wong, 2022/01/23
- [PATCH 2/9] player: remove omap conversion, Eric Wong, 2022/01/23
- [PATCH 3/9] dtas: drop unnecessary "require 'yaml'" statements, Eric Wong, 2022/01/23
- [PATCH 4/9] dtas-tl prune: cull missing files from tracklist, Eric Wong, 2022/01/23
- [PATCH 5/9] dtas-tl: drop encoding hacks, use binary stdout+stderr,
Eric Wong <=
- [PATCH 6/9] use IO#wait_readable consistently, Eric Wong, 2022/01/23
- [PATCH 7/9] get rid of DTAS::Nonblock wrapper for Ruby <= 2.0, Eric Wong, 2022/01/23
- [PATCH 8/9] unix_accepted: drop Ruby < 2.3 support code, Eric Wong, 2022/01/23
- [PATCH 9/9] do not check IO#closed? before calling IO#close, Eric Wong, 2022/01/23