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

pengzheng pushed a commit to branch feature/522-support-uncompressed-bundle
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 60627426306a3f90a4c4102904260463e6721f0e
Author: PengZheng <[email protected]>
AuthorDate: Mon Jun 26 17:28:56 2023 +0800

    Use the last modification time of the bundle archive cache dir rather than 
that of the manifest.
    
    Note that for and uncompressed bundle, these two modification timestamps 
might be different, which may lead to superfluous disk write when uncompressed 
bundle is supported.
---
 .../src/BundleArchiveWithErrorInjectionTestSuite.cc     |  4 ++--
 libs/framework/include_deprecated/bundle_archive.h      |  2 +-
 libs/framework/src/bundle_archive.c                     | 17 ++---------------
 libs/framework/src/bundle_archive_private.h             |  5 -----
 4 files changed, 5 insertions(+), 23 deletions(-)

diff --git 
a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc 
b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
index 942b8e45..4861ea44 100644
--- a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
+++ b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
@@ -185,8 +185,8 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, 
ArchiveCreateErrorTest) {
     bundle_archive_t* archive = nullptr;
 
     // archive directory creation failures not covered by other tests
-    
celix_ei_expect_celix_utils_writeOrCreateString((void*)celix_bundleArchive_getLastModifiedInternal,
 0, nullptr);
-    EXPECT_EQ(CELIX_ENOMEM,
+    
celix_ei_expect_celix_utils_getLastModified((void*)celix_bundleArchive_create, 
2, CELIX_FILE_IO_EXCEPTION);
+    EXPECT_EQ(CELIX_FILE_IO_EXCEPTION,
               celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 1, 
SIMPLE_TEST_BUNDLE1_LOCATION, &archive));
     EXPECT_EQ(nullptr, archive);
     EXPECT_FALSE(celix_utils_directoryExists(TEST_ARCHIVE_ROOT));
diff --git a/libs/framework/include_deprecated/bundle_archive.h 
b/libs/framework/include_deprecated/bundle_archive.h
index daa9b0aa..d53518a1 100644
--- a/libs/framework/include_deprecated/bundle_archive.h
+++ b/libs/framework/include_deprecated/bundle_archive.h
@@ -90,7 +90,7 @@ CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_status_t 
bundleArchive_getPersistentStat
 /**
  * @brief Return the last modified time of the bundle archive.
  *
- * The last modified time is based on the last modified time of the bundle 
archives MANIFEST.MF file.
+ * The last modified time is based on the last modified time of the bundle 
archive cache directory.
  *
  * If the bundle archive cache directory does not exist, lastModified will be 
set to 0.
  *
diff --git a/libs/framework/src/bundle_archive.c 
b/libs/framework/src/bundle_archive.c
index e977fe6f..9bb0b0fd 100644
--- a/libs/framework/src/bundle_archive.c
+++ b/libs/framework/src/bundle_archive.c
@@ -103,7 +103,7 @@ celix_bundleArchive_extractBundle(bundle_archive_t* 
archive, const char* bundleU
 
     //get revision mod time;
     struct timespec revisionMod;
-    status = celix_bundleArchive_getLastModifiedInternal(archive, 
&revisionMod);
+    status = celix_utils_getLastModified(archive->resourceCacheRoot, 
&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;
@@ -396,23 +396,10 @@ celix_status_t 
bundleArchive_getLastModified(bundle_archive_pt archive, time_t*
 }
 //LCOV_EXCL_STOP
 
-celix_status_t celix_bundleArchive_getLastModifiedInternal(bundle_archive_pt 
archive, struct timespec* lastModified) {
-    // precondition: archive->lock is locked
-    celix_status_t status = CELIX_SUCCESS;
-    char manifestPathBuffer[CELIX_DEFAULT_STRING_CREATE_BUFFER_SIZE];
-    char* manifestPath = celix_utils_writeOrCreateString(manifestPathBuffer, 
sizeof(manifestPathBuffer), "%s/%s", archive->resourceCacheRoot, 
CELIX_BUNDLE_MANIFEST_REL_PATH);
-    if (manifestPath == NULL) {
-        status = CELIX_ENOMEM;
-    }
-    status = CELIX_DO_IF(status, celix_utils_getLastModified(manifestPath, 
lastModified));
-    celix_utils_freeStringIfNotEqual(manifestPathBuffer, manifestPath);
-    return status;
-}
-
 celix_status_t celix_bundleArchive_getLastModified(bundle_archive_pt archive, 
struct timespec* lastModified) {
     celix_status_t status;
     celixThreadMutex_lock(&archive->lock);
-    status = celix_bundleArchive_getLastModifiedInternal(archive, 
lastModified);
+    status = celix_utils_getLastModified(archive->resourceCacheRoot, 
lastModified);
     celixThreadMutex_unlock(&archive->lock);
     return status;
 }
diff --git a/libs/framework/src/bundle_archive_private.h 
b/libs/framework/src/bundle_archive_private.h
index 379213ea..b6a837d9 100644
--- a/libs/framework/src/bundle_archive_private.h
+++ b/libs/framework/src/bundle_archive_private.h
@@ -75,11 +75,6 @@ const char* 
celix_bundleArchive_getPersistentStoreRoot(bundle_archive_t *archive
   */
 const char* celix_bundleArchive_getCurrentRevisionRoot(bundle_archive_pt 
archive);
 
-/**
- * Return the last modified time of the bundle archive.
- */
-celix_status_t celix_bundleArchive_getLastModifiedInternal(bundle_archive_pt 
archive, struct timespec* lastModified);
-
 #ifdef __cplusplus
 }
 #endif

Reply via email to