From d753e36b0290befa202324b9095807878cd13b8d Mon Sep 17 00:00:00 2001 From: abyss-w <75366604+abyss-w@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:10:10 +0800 Subject: [PATCH] fix: Fixed the List method repeatedly placing objects into the channel to be migrated (#336) --- migrate/copy.go | 1 + migrate/list.go | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/migrate/copy.go b/migrate/copy.go index 85e8c7d..8829880 100644 --- a/migrate/copy.go +++ b/migrate/copy.go @@ -72,6 +72,7 @@ func copyTask(ctx context.Context) (err error) { } if !isFinished(ctx) { + //t.Status = constants.TaskStatusRerun return constants.ErrTaskNotFinished } diff --git a/migrate/list.go b/migrate/list.go index ab9b111..57dc5b4 100644 --- a/migrate/list.go +++ b/migrate/list.go @@ -27,26 +27,14 @@ func List(ctx context.Context) (err error) { if err != nil { logrus.Panic(err) } - } - - // Traverse already running but not finished directory object. - p := "" - for { - do, err := model.NextDirectoryObject(ctx, p) - if err != nil { - logrus.Panic(err) - } - if do == nil { - break - } jwg.Add(1) - jc <- do - p = do.Key + jc <- o + return nil } // Traverse already running but not finished single object. - p = "" + p := "" for { so, err := model.NextSingleObject(ctx, p) if err != nil { @@ -77,6 +65,22 @@ func List(ctx context.Context) (err error) { pn = po.PartNumber } + // Traverse already running but not finished directory object. + p = "" + for { + do, err := model.NextDirectoryObject(ctx, p) + if err != nil { + logrus.Panic(err) + } + if do == nil { + break + } + + jwg.Add(1) + jc <- do + p = do.Key + } + return }