Fix WebDav not using Global FS but Flash cannot compile

This commit is contained in:
Luc 2024-02-15 12:36:55 +08:00
parent b56148c895
commit 3f5daa5381
3 changed files with 38 additions and 5 deletions

View File

@ -22,7 +22,7 @@
#define _VERSION_ESP3D_H
// version and sources location
#define FW_VERSION "3.0.0.a230"
#define FW_VERSION "3.0.0.a231"
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
#endif //_VERSION_ESP3D_H

View File

@ -86,9 +86,20 @@ void WebdavServer::handler_copy(const char* url) {
overwrite = true;
}
// check available space
#if WEBDAV_FEATURE == FS_ROOT
uint64_t free_space = WebDavFS::freeBytes(fsTypeDestination);
#else
#if WEBDAV_FEATURE == FS_FLASH
size_t free_space;
#endif
#if WEBDAV_FEATURE == FS_SD
uint64_t free_space;
#endif
free_space = WebDavFS::freeBytes();
#endif
if (overwrite) {
if (WebDavFS::exists(destination.c_str())) {
if (WebDavFS::freeBytes(fsTypeOrigin) + fileOrigin.size() <
if (free_space + fileOrigin.size() <
fileDestination.size()) {
code = 507;
esp3d_log_e("Not enough space");
@ -97,7 +108,7 @@ void WebdavServer::handler_copy(const char* url) {
code = 204;
}
} else {
if (WebDavFS::freeBytes(fsTypeOrigin) < fileOrigin.size()) {
if (free_space < fileOrigin.size()) {
code = 507;
esp3d_log_e("Not enough space");
overwrite = false;

View File

@ -58,7 +58,18 @@ void WebdavServer::handler_put(const char* url) {
file.close();
if (!hasError) {
// check size available
if (WebDavFS::freeBytes(fsType) + file.size() < content_length) {
#if WEBDAV_FEATURE == FS_ROOT
uint64_t free_space = WebDavFS::freeBytes(fsType);
#else
#if WEBDAV_FEATURE == FS_FLASH
size_t free_space;
#endif
#if WEBDAV_FEATURE == FS_SD
uint64_t free_space;
#endif
free_space = WebDavFS::freeBytes();
#endif
if (free_space + file.size() < content_length) {
code = 507;
esp3d_log_e("Not enough space");
hasError = true;
@ -78,7 +89,18 @@ void WebdavServer::handler_put(const char* url) {
}
} else {
// check size available
if (WebDavFS::freeBytes(fsType) < content_length) {
#if WEBDAV_FEATURE == FS_ROOT
uint64_t free_space = WebDavFS::freeBytes(fsType);
#else
#if WEBDAV_FEATURE == FS_FLASH
size_t free_space;
#endif
#if WEBDAV_FEATURE == FS_SD
uint64_t free_space;
#endif
free_space = WebDavFS::freeBytes();
#endif
if (free_space < content_length) {
code = 507;
esp3d_log_e("Not enough space");
hasError = true;