From d36e2183c4998747237ea381afc38ebf1e4049ab Mon Sep 17 00:00:00 2001
From: mvelosob <miguel.veloso.barros@cern.ch>
Date: Wed, 8 Jun 2022 09:45:19 +0200
Subject: [PATCH] Fix tapeserver popping the entire archive queue at the end of
 the mount (#1225)

---
 ReleaseNotes.md                                               | 4 +++-
 .../castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ReleaseNotes.md b/ReleaseNotes.md
index e9b806cb84..0a96596d64 100644
--- a/ReleaseNotes.md
+++ b/ReleaseNotes.md
@@ -6,7 +6,10 @@ This release introduced an additional gRPC based frontend for storage backends.
 
 ### Upgrade Instructions
 ### Features
+- cta/CTA#1222 - Add minimal gRPC based frOntend for integration with dCache
+
 ### Bug fixes
+- cta/CTA#1225 - Fix bug causing tapeserver to sometimes pop the entire archive queue at the end of the mount
 ### Building and Packaging
 ### Catalogue Schema
 
@@ -22,7 +25,6 @@ This release introduced an additional gRPC based frontend for storage backends.
 - cta/CTA#1152 - Reduce eos free space query load
 - cta/CTA#1231 - Add --loadtimeout option to cta-tape-label and increase default value
 - cta/CTA#977 - Add --drive option to cta-tape-label
-- cta/CTA#1222 - Add minimal gRPC based forntend for integration with dCache
 
 ### Bug fixes
 - cta/CTA#1120 - Fix negative disk space reservation content
diff --git a/tapeserver/castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp b/tapeserver/castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp
index a55fa9874c..15100e19f6 100644
--- a/tapeserver/castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp
+++ b/tapeserver/castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp
@@ -145,7 +145,7 @@ private:
     filesRequested(mf), bytesRequested(mb), lastCall(lc), end(false) {}
     
     Request():
-    filesRequested(-1), bytesRequested(-1), lastCall(true),end(true) {}
+    filesRequested(0), bytesRequested(0), lastCall(true), end(true) {}
     
     const uint64_t filesRequested;
     const uint64_t bytesRequested;
-- 
GitLab