This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch feature/refactor_bundle_cache
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/refactor_bundle_cache 
by this push:
     new ddcafa52 Minor improvement of `celix_bundleArchive_extractBundle`
ddcafa52 is described below

commit ddcafa52b74c3061f45f3981324b45452f725fc1
Author: PengZheng <[email protected]>
AuthorDate: Fri Mar 24 21:26:01 2023 +0800

    Minor improvement of `celix_bundleArchive_extractBundle`
---
 libs/framework/src/bundle_archive.c         | 31 +++++++++++++----------------
 libs/framework/src/bundle_archive_private.h |  9 +++------
 2 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/libs/framework/src/bundle_archive.c 
b/libs/framework/src/bundle_archive.c
index d644f5b9..1a8b1114 100644
--- a/libs/framework/src/bundle_archive.c
+++ b/libs/framework/src/bundle_archive.c
@@ -86,14 +86,22 @@ static void 
celix_bundleArchive_storeBundleStateProperties(bundle_archive_pt arc
 celix_status_t celix_bundleArchive_extractBundle(
         bundle_archive_t* archive,
         const char* revisionRoot,
-        const char* bundleUrl,
-        const struct timespec* revisionModificationTime) {
+        const char* bundleUrl) {
     celix_status_t status = CELIX_SUCCESS;
     bool extractBundle = true;
 
+    //get revision mod time;
+    struct timespec revisionMod;
+    status = celix_bundleArchive_getLastModifiedInternal(archive, 
&revisionMod);
+    if (status != CELIX_SUCCESS && errno != ENOENT) {
+        fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed 
to get last modified time for bundle archive revision directory '%s'", 
archive->resourceCacheRoot);
+        return status;
+    }
+
+
     //check if bundle location is newer than current revision
-    if (revisionModificationTime != NULL) {
-        extractBundle = 
celix_framework_utils_isBundleUrlNewerThan(archive->fw, bundleUrl, 
revisionModificationTime);
+    if (status == CELIX_SUCCESS) {
+        extractBundle = 
celix_framework_utils_isBundleUrlNewerThan(archive->fw, bundleUrl, 
&revisionMod);
     }
 
     if (!extractBundle) {
@@ -165,17 +173,8 @@ celix_status_t 
celix_bundleArchive_createCacheDirectory(bundle_archive_pt archiv
         return status;
     }
 
-    //get revision mod time;
-    struct timespec revisionMod;
-    status = celix_bundleArchive_getLastModifiedInternal(archive, 
&revisionMod);
-    if (status != CELIX_SUCCESS && errno != ENOENT) {
-        fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed 
to get last modified time for bundle archive revision directory '%s'", 
archive->resourceCacheRoot);
-        return status;
-    }
-
     //extract bundle zip to revision directory
-    status = celix_bundleArchive_extractBundle(archive, 
archive->resourceCacheRoot, archive->location,
-                                               status == CELIX_SUCCESS ? 
&revisionMod : NULL);
+    status = celix_bundleArchive_extractBundle(archive, 
archive->resourceCacheRoot, archive->location);
     if (status != CELIX_SUCCESS) {
         fw_log(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, "Failed to 
initialize archive. Failed to extract bundle.");
         return status;
@@ -401,10 +400,8 @@ celix_status_t bundleArchive_revise(bundle_archive_pt 
archive, const char * loca
         updateUrl = updatedBundleUrl;
     }
 
-    struct timespec lastModified;
     const char *reason = NULL;
-    celix_bundleArchive_getLastModifiedInternal(archive, &lastModified);
-    celix_status_t status = celix_bundleArchive_extractBundle(archive, 
archive->resourceCacheRoot, updateUrl, &lastModified);
+    celix_status_t status = celix_bundleArchive_extractBundle(archive, 
archive->resourceCacheRoot, updateUrl);
     if (status == CELIX_SUCCESS) {
         bundle_revision_t* current = archive->revision;
         bundle_revision_t* revised = bundleRevision_revise(current, updateUrl);
diff --git a/libs/framework/src/bundle_archive_private.h 
b/libs/framework/src/bundle_archive_private.h
index 00640e55..f06dbb93 100644
--- a/libs/framework/src/bundle_archive_private.h
+++ b/libs/framework/src/bundle_archive_private.h
@@ -67,12 +67,9 @@ const char* 
celix_bundleArchive_getSymbolicName(bundle_archive_pt archive);
  */
 const char* celix_bundleArchive_getPersistentStoreRoot(bundle_archive_t 
*archive);
 
-/**
- * Get the last modified time of the current bundle revision.
- * @param[in] archive The bundle archive.
- * @return The current revision root
- * @retval NULL if the current revision root is not set.
- */
+ /**
+  * Returns the root of the current revision.
+  */
 const char* celix_bundleArchive_getCurrentRevisionRoot(bundle_archive_pt 
archive);
 
 #ifdef __cplusplus

Reply via email to