From b81e37f6abb317a4d696335b4a361a23d03ca7d3 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 4 Feb 2021 09:39:16 +0100 Subject: [PATCH] tape: improve code reuse --- src/tape/media_pool.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/tape/media_pool.rs b/src/tape/media_pool.rs index 8ee3e7da..c4eabcfc 100644 --- a/src/tape/media_pool.rs +++ b/src/tape/media_pool.rs @@ -467,16 +467,11 @@ impl MediaPool { match media.status() { MediaStatus::Full => { /* OK */ }, MediaStatus::Writable if (seq + 1) == media_count => { - match media.location() { - MediaLocation::Online(_) => { - last_is_writable = true; - }, - MediaLocation::Offline => { - if self.use_offline_media { - last_is_writable = true; - } - } - MediaLocation::Vault(vault) => { + let media_location = media.location(); + if self.location_is_available(media_location) { + last_is_writable = true; + } else { + if let MediaLocation::Vault(vault) = media_location { bail!("writable media offsite in vault '{}'", vault); } }