celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [12/38] celix git commit: CELIX-288: Fix in finding highest bundle archive version
Date Tue, 17 Nov 2015 11:57:29 GMT
CELIX-288: Fix in finding highest bundle archive version


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/90b92ffd
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/90b92ffd
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/90b92ffd

Branch: refs/heads/develop
Commit: 90b92ffd0d923aca6edb8bf4577261b7fa5b478b
Parents: 1836ed4
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Thu Nov 12 17:38:16 2015 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Thu Nov 12 17:40:27 2015 +0100

----------------------------------------------------------------------
 framework/private/src/bundle_archive.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/90b92ffd/framework/private/src/bundle_archive.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_archive.c b/framework/private/src/bundle_archive.c
index f7add7e..6df7270 100644
--- a/framework/private/src/bundle_archive.c
+++ b/framework/private/src/bundle_archive.c
@@ -189,10 +189,11 @@ celix_status_t bundleArchive_recreate(char * archiveRoot, bundle_archive_pt
*bun
 		} else {
 
             long idx = 0;
+            long highestId = -1;
             char *location = NULL;
 
 			struct dirent dent;
-			struct dirent *result;
+			struct dirent *result = NULL;
             struct stat st;
 			int rc;
 
@@ -203,15 +204,15 @@ celix_status_t bundleArchive_recreate(char * archiveRoot, bundle_archive_pt
*bun
                 stat(subdir, &st);
 				if (S_ISDIR(st.st_mode) && (strncmp(dent.d_name, "version", 7) == 0)) {
 					sscanf(dent.d_name, "version%*d.%ld", &idx);
-				} else {
-                    status = CELIX_FILE_IO_EXCEPTION;
-                    break;
-                }
+                    if (idx > highestId) {
+                        highestId = idx;
+                    }
+				}
 				rc = readdir_r(archive->archiveRootDir, &dent, &result);
 			}
 
             status = CELIX_DO_IF(status, bundleArchive_getRevisionLocation(archive, 0, &location));
-            status = CELIX_DO_IF(status, bundleArchive_reviseInternal(archive, true, idx,
location, NULL));
+            status = CELIX_DO_IF(status, bundleArchive_reviseInternal(archive, true, highestId,
location, NULL));
             if (location) {
                 free(location);
             }
@@ -668,7 +669,10 @@ static celix_status_t bundleArchive_initialize(bundle_archive_pt archive)
{
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->archiveRootDir == NULL) {
-	    if (mkdir(archive->archiveRoot, S_IRWXU) != 0) {
+        int err = mkdir(archive->archiveRoot, S_IRWXU) ;
+	    if (err != 0) {
+            char *errmsg = strerror(errno);
+            fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error mkdir: %s\n", errmsg);
 			status = CELIX_FILE_IO_EXCEPTION;
 		} else {
 		    archive->archiveRootDir = opendir(archive->archiveRoot);


Mime
View raw message