Files
MatchLiveTv/backend/app/services/streams/cover_slate_paths.rb
eminuxandCursor 0702cb699c Rendi affidabile pausa con slate e conferma i controlli laterali.
Evita buchi HLS/YouTube in pausa (path slate ricreata, reload player, no patch recording inutili) e richiede conferma su tasti laterali app/regia.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-20 12:44:23 +02:00

36 lines
903 B
Ruby

module Streams
class CoverSlatePaths
def self.slates_custom_root
ENV.fetch("MEDIAMTX_SLATES_CUSTOM_DIR", "/slates/custom")
end
# ActiveStorage checksum is base64 e può contenere "/", "+", "=" — non usabile come path.
def self.safe_digest(checksum)
checksum.to_s.tr("+/", "-_").delete("=")
end
def self.filename_for(record)
return nil unless record.cover_slate.attached?
digest = safe_digest(record.cover_slate.blob.checksum)
prefix = record.class.name.underscore
"#{prefix}-#{record.id}-#{digest}.mp4"
end
def self.expected_path(record)
name = filename_for(record)
return nil if name.blank?
File.join(slates_custom_root, name)
end
def self.local_path_for(record)
path = expected_path(record)
return nil if path.blank?
return path if File.exist?(path)
nil
end
end
end