From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-2.3 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 69CCB1F575 for ; Mon, 29 Dec 2014 12:21:48 +0000 (UTC) Received: from localhost ([::1]:33095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5ZKV-00083D-QJ for dtas-all@80x24.org; Mon, 29 Dec 2014 07:21:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5ZKN-0007wf-7k for dtas-all@nongnu.org; Mon, 29 Dec 2014 07:21:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y5ZKC-0005MZ-Ps for dtas-all@nongnu.org; Mon, 29 Dec 2014 07:21:34 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:36147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5ZKC-0005MT-J8 for dtas-all@nongnu.org; Mon, 29 Dec 2014 07:21:28 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5C0541F466 for ; Mon, 29 Dec 2014 12:21:25 +0000 (UTC) From: Eric Wong To: Subject: [PATCH] source/splitfx: fail gracefully on missing files Date: Mon, 29 Dec 2014 12:21:25 +0000 Message-Id: <1419855685-4476-2-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.2.1.202.g55b961f X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org We cannot afford to break the entire player because somebody enqueued a non-existent file (or enqueued and later renamed it). --- lib/dtas/source/splitfx.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/dtas/source/splitfx.rb b/lib/dtas/source/splitfx.rb index 2b10e5c..5340f3d 100644 --- a/lib/dtas/source/splitfx.rb +++ b/lib/dtas/source/splitfx.rb @@ -33,23 +33,22 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: end sfx = DTAS::SplitFX.new - begin - Dir.chdir(File.dirname(ymlfile)) do # ugh - @ymlhash = YAML.load(buf) - @ymlhash['tracks'] ||= [ "t 0 default" ] - sfx.import(@ymlhash) - sfx.infile.replace(File.expand_path(sfx.infile)) - end - @splitfx = sfx - rescue - return false + Dir.chdir(File.dirname(ymlfile)) do # ugh + @ymlhash = YAML.load(buf) + @ymlhash['tracks'] ||= [ "t 0 default" ] + sfx.import(@ymlhash) + sfx.infile.replace(File.expand_path(sfx.infile)) end + @splitfx = sfx @infile = ymlfile sox = @sox.try(sfx.infile, offset) or return false rv = source_file_dup(ymlfile, offset) rv.sox = sox rv.env = sfx.env rv + rescue => e + warn "#{e.message} (#{e.class})" + false end def __load_comments -- EW