Skip to content

Commit

Permalink
Fix for issue #10 - problem with saving files.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Apr 27, 2023
1 parent 138d773 commit d3a0416
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions fs_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ vfs_drive_t *fs_get_sd_drive (void)
if((dh = vfs_drives_open()))
{
while((drive = vfs_drives_read(dh))) {
if(!strcmp(drive->name, "FatFs")) {
if(drive->removable) {
memcpy(&sd, drive, sizeof(vfs_drive_t));
break;
}
Expand All @@ -493,7 +493,7 @@ vfs_drive_t *fs_get_flash_drive (void)
if((dh = vfs_drives_open()))
{
while((drive = vfs_drives_read(dh))) {
if(!strcmp(drive->name, "spiffs") || !strcmp(drive->name, "littlefs")) {
if(!(drive->removable || drive->mode.read_only)) {
memcpy(&flash, drive, sizeof(vfs_drive_t));
break;
}
Expand Down
13 changes: 9 additions & 4 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,18 @@ const char *file_redirect (http_request_t *request, const char *uri, vfs_file_t
}
#endif

if(file_search(path, "/index.html.gz", file, mode)) {
if(file_search(path, "/index.html.gz", file, mode))
request->encoding = HTTPEncoding_GZIP;
else
file_search(path, "/index.html", file, mode);

if(*file) {
char *s = strstr(path, "index.html");
if(s)
*s = '\0';
strcpy(sys_path, path);
vfs_fixpath(path);
strcpy(sys_path, flashfs == NULL || strcmp(path, "/embedded") ? path : flashfs->path);
uri = "/index.html";
request->encoding = HTTPEncoding_GZIP;
}
} else if(!strcmp(uri, "/favicon.ico") || !strcmp(uri, "/preferences.json"))
file_search(strcpy(path, *sys_path == '\0' ? "/" : sys_path), uri, file, mode);
Expand All @@ -764,7 +769,7 @@ const char *file_redirect (http_request_t *request, const char *uri, vfs_file_t
#endif

if(*file == NULL && strlookup(".gz", uri, '.') == -1) {
if((*file = vfs_open(strcat(uri, ".gz"), mode)))
if((*file = vfs_open(strcat((char *)uri, ".gz"), mode)))
request->encoding = HTTPEncoding_GZIP;
*(strchr(uri, '\0') - 3) = '\0';
}
Expand Down

0 comments on commit d3a0416

Please sign in to comment.