From bbcc4c58d67aeceee55fcc1126deedafe0e43c20 Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Tue, 14 Mar 2023 20:32:23 -0700
Subject: [PATCH 53/56] bugfix can't delete layers under dir overlay-layers

Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
 .../modules/image/oci/storage/layer_store/layer_store.c   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
index 29ead711..680b35a2 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
@@ -1412,10 +1412,14 @@ static int do_delete_layer(const char *id)
     }
 
 #ifdef ENABLE_REMOTE_LAYER_STORE
-    if (l->slayer->writable) {
+    if (!g_enable_remote_layer) {
         ret = layer_store_remove_layer(l->slayer->id);
     } else {
-        ret = remote_layer_remove_ro_dir(l->slayer->id);
+        if (l->slayer->writable) {
+            ret = layer_store_remove_layer(l->slayer->id);
+        } else {
+            ret = remote_layer_remove_ro_dir(l->slayer->id);
+        }
     }
 #else
     ret = layer_store_remove_layer(l->slayer->id);
-- 
2.25.1

