[ISSUE-65161406] Use transactions. Remove temp files for failed bundle-downloading.
diff --git a/bundle.go b/bundle.go
index 468760c..54636da 100644
--- a/bundle.go
+++ b/bundle.go
@@ -176,6 +176,9 @@
 
 	if err != nil {
 		log.Errorf("Unable to download blob file blobId=%s err:%v", r.blobId, err)
+		if downloadedFile != "" && os.Remove(downloadedFile) != nil {
+			log.Debugf("Unable to remove temp file %s", downloadedFile)
+		}
 		return err
 	}
 
@@ -184,10 +187,13 @@
 	err = r.bm.dbMan.updateLocalFsLocation(r.blobId, downloadedFile)
 	if err != nil {
 		log.Errorf("updateLocalFsLocation failed: blobId=%s", r.blobId)
+		if downloadedFile != "" && os.Remove(downloadedFile) != nil {
+			log.Debugf("Unable to remove temp file %s", downloadedFile)
+		}
 		return err
 	}
 
-	log.Debugf("bundle downloaded: blobId=%s", r.blobId)
+	log.Debugf("bundle downloaded: blobId=%s filename=%s", r.blobId, downloadedFile)
 
 	// TODO send changed deployments to subscribers (API call with "block")
 	//r.bm.apiMan.addChangedDeployment(dep.ID)
diff --git a/data.go b/data.go
index 607c0ab..e1ac8fb 100644
--- a/data.go
+++ b/data.go
@@ -190,19 +190,21 @@
 }
 
 func (dbc *dbManager) updateLocalFsLocation(blobId, localFsLocation string) error {
-
-	stmt, err := dbc.getDb().Prepare(`
+	txn, err := dbc.getDb().Begin()
+	if err != nil {
+		return err
+	}
+	defer txn.Rollback()
+	_, err = txn.Exec(`
 		INSERT OR IGNORE INTO apid_blob_available (
 		id,
 		local_fs_location
-		) VALUES (?, ?);`)
+		) VALUES (?, ?);`, blobId, localFsLocation)
 	if err != nil {
-		log.Errorf("PREPARE updateLocalFsLocation failed: %v", err)
+		log.Errorf("INSERT apid_blob_available id {%s} local_fs_location {%s} failed", localFsLocation, err)
 		return err
 	}
-	defer stmt.Close()
-
-	_, err = stmt.Exec(blobId, localFsLocation)
+	err = txn.Commit()
 	if err != nil {
 		log.Errorf("UPDATE apid_blob_available id {%s} local_fs_location {%s} failed", localFsLocation, err)
 		return err