Skip to content

Commit

Permalink
Fix download error in Firebase Storage and Google Cloud Storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jul 29, 2023
1 parent ff8b3a4 commit 25f3c1b
Show file tree
Hide file tree
Showing 47 changed files with 85 additions and 69 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Firebase Arduino Client Library for ESP8266 and ESP32",
"version": "4.3.18",
"version": "4.3.19",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Firebase Arduino Client Library for ESP8266 and ESP32

version=4.3.18
version=4.3.19

author=Mobizt

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Const.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Error.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Network.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Firebase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Firebase.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FirebaseFS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/Firebase_Client_Version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef FIREBASE_CLIENT_VERSION
#define FIREBASE_CLIENT_VERSION "4.3.18"
#define FIREBASE_CLIENT_VERSION_NUM 40318
#define FIREBASE_CLIENT_VERSION "4.3.19"
#define FIREBASE_CLIENT_VERSION_NUM 40319

/* The inconsistent file version checking to prevent mixed versions compilation. */
#define FIREBASE_CLIENT_VERSION_CHECK(ver) (ver == FIREBASE_CLIENT_VERSION_NUM)
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/FB_Firestore.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/firestore/FB_Firestore.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FB_Functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FB_Functions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FunctionsConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FunctionsConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/PocicyBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/PolicyBuilder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/gcs/GCS.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

/**
* Google's Cloud Storage class, GCS.cpp version 1.2.10
* Google's Cloud Storage class, GCS.cpp version 1.2.11
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 11, 2023
* Created July 29, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -1203,7 +1203,7 @@ bool GG_CloudStorage::handleResponse(FirebaseData *fbdo, struct fb_esp_gcs_req_t

if (req->requestType == fb_esp_gcs_request_type_download &&
strlen(Signer.mbfs->name(mbfs_type req->storageType)) == 0 &&
!fbdo->prepareDownload(req->localFileName, req->storageType))
!fbdo->prepareDownload(req->localFileName, req->storageType, true))
return false;

bool ruTask = req->requestType == fb_esp_gcs_request_type_upload_resumable_init ||
Expand Down
6 changes: 3 additions & 3 deletions src/gcs/GCS.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

/**
* Google's Cloud Storage class, GCS.h version 1.2.10
* Google's Cloud Storage class, GCS.h version 1.2.11
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 11, 2023
* Created July 29, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
2 changes: 1 addition & 1 deletion src/message/FCM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/FCM.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/rtdb/FB_RTDB.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Realtime Database class, FB_RTDB.cpp version 2.0.17
* Google's Firebase Realtime Database class, FB_RTDB.cpp version 2.0.18
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 11, 2023
* Created July 29, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -2355,7 +2355,7 @@ bool FB_RTDB::handleResponse(FirebaseData *fbdo, fb_esp_rtdb_request_info_t *req
}

if ((req->task_type == fb_esp_rtdb_task_download_rules || req->method == rtdb_backup) &&
!fbdo->prepareDownload(req->filename, (fb_esp_mem_storage_type)req->storageType))
!fbdo->prepareDownload(req->filename, (fb_esp_mem_storage_type)req->storageType, false))
return false;

bool complete = false;
Expand Down
6 changes: 3 additions & 3 deletions src/rtdb/FB_RTDB.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Realtime Database class, FB_RTDB.h version 2.0.17
* Google's Firebase Realtime Database class, FB_RTDB.h version 2.0.18
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 11, 2023
* Created July 29, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueryFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueryFilter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueInfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueueManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_MP_Stream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_MP_Stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_Stream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/stream/FB_Stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
24 changes: 20 additions & 4 deletions src/session/FB_Session.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Data class, FB_Session.cpp version 1.3.9
* Google's Firebase Data class, FB_Session.cpp version 1.3.10
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 11, 2023
* Created July 29, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -1073,7 +1073,7 @@ bool FirebaseData::readResponse(MB_String *payload, struct fb_esp_tcp_response_h
return true;
}

bool FirebaseData::prepareDownload(const MB_String &filename, fb_esp_mem_storage_type type)
bool FirebaseData::prepareDownload(const MB_String &filename, fb_esp_mem_storage_type type, bool openFileInWrireMode)
{
if (!Signer.config)
return false;
Expand All @@ -1083,6 +1083,19 @@ bool FirebaseData::prepareDownload(const MB_String &filename, fb_esp_mem_storage
// We can't open file (flash or sd) to write here because of truncated result, only append is ok.
// We have to remove existing file
Signer.mbfs->remove(filename, mbfs_type type);
#else
// File need to be opened in case non-RTDB class.
// In RTDB class, it handles file opening differently.
if (openFileInWrireMode)
{
int ret = Signer.mbfs->open(filename, mbfs_type type, mb_fs_open_mode_write);
if (ret < 0)
{
tcpClient.flush();
session.response.code = ret;
return false;
}
}
#endif
return true;
}
Expand Down Expand Up @@ -1299,6 +1312,9 @@ bool FirebaseData::processDownload(const MB_String &filename, fb_esp_mem_storage
#if defined(ESP32_GT_2_0_1_FS_MEMORY_FIX)
// We close file here after append
Signer.mbfs->close(mbfs_type type);
#else
if (tcpHandler.error.code == MB_FS_ERROR_FILE_IO_ERROR)
Signer.mbfs->close(mbfs_type type);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/session/FB_Session.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

/**
* Google's Firebase Data class, FB_Session.h version 1.3.9
* Google's Firebase Data class, FB_Session.h version 1.3.10
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 11, 2023
* Created July 29, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -1013,7 +1013,7 @@ class FirebaseData
struct server_response_data_t &response);
bool readResponse(MB_String *payload, struct fb_esp_tcp_response_handler_t &tcpHandler,
struct server_response_data_t &response);
bool prepareDownload(const MB_String &filename, fb_esp_mem_storage_type type);
bool prepareDownload(const MB_String &filename, fb_esp_mem_storage_type type, bool openFileInWrireMode = false);
void prepareDownloadOTA(struct fb_esp_tcp_response_handler_t &tcpHandler, struct server_response_data_t &response);
void endDownloadOTA(struct fb_esp_tcp_response_handler_t &tcpHandler);
bool processDownload(const MB_String &filename, fb_esp_mem_storage_type type, uint8_t *buf,
Expand Down
2 changes: 1 addition & 1 deletion src/signer/Signer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40318)
#if !FIREBASE_CLIENT_VERSION_CHECK(40319)
#error "Mixed versions compilation."
#endif

Expand Down
Loading

0 comments on commit 25f3c1b

Please sign in to comment.