chart data rotate stuff wip
This commit is contained in:
parent
f4586f17fc
commit
a3f99e83bf
1 changed files with 7 additions and 5 deletions
|
@ -810,8 +810,7 @@ void LFS_Chart_Rotate_Data(const byte chartId) {
|
|||
//timestampNow_char = Char_Timestamp_yyyymmdd(now());
|
||||
|
||||
/* timestamp of the oldest file allowed. Anything older gets deleted. convert to unsigned long */
|
||||
/* now() returns time_t , i need to substract the difference an long unsigned */
|
||||
//unsigned long tmp_timestampOldest = now() - (3 * TIMESCALE_MINUTE);
|
||||
|
||||
unsigned long timestampOldest = strtoul(Char_Timestamp_yyyymmdd(now() - (3 * Timescale(TIMESCALE_MINUTE))), NULL, 0);
|
||||
|
||||
char chartDirPath[10];
|
||||
|
@ -820,6 +819,9 @@ void LFS_Chart_Rotate_Data(const byte chartId) {
|
|||
/* https://github.com/cotestatnt/async-esp-fs-webserver/blob/master/src/AsyncFsWebServer.cpp */
|
||||
File root = LittleFS.open(chartDirPath, "r");
|
||||
File file = root.openNextFile();
|
||||
#ifdef DEBUG
|
||||
Log.verbose(F("%s timestampOldest %u" CR), LogLoc, timestampOldest);
|
||||
#endif
|
||||
while (file) {
|
||||
if (!file.isDirectory()) {
|
||||
/* https://cplusplus.com/reference/cstdlib/strtoul/ */
|
||||
|
@ -830,7 +832,7 @@ void LFS_Chart_Rotate_Data(const byte chartId) {
|
|||
//timestampFile_char = file.name();
|
||||
unsigned long timestampFile = strtoul(file.name(), NULL, 0);
|
||||
#ifdef DEBUG
|
||||
Log.verbose(F("%s timestampOldest %u - timestampFile %u" CR), LogLoc, timestampOldest, timestampFile);
|
||||
Log.verbose(F("%s - timestampFile %u" CR), LogLoc, timestampFile);
|
||||
#endif
|
||||
|
||||
/* if timestamp is older then oldest allowed, delete it */
|
||||
|
@ -840,11 +842,11 @@ void LFS_Chart_Rotate_Data(const byte chartId) {
|
|||
snprintf(pathDelete, sizeof(pathDelete), "%s/%s", chartDirPath, file.name());
|
||||
if(LittleFS.remove(pathDelete)) {
|
||||
#ifdef DEBUG
|
||||
Log.verbose(F("%s deleted %u" CR), LogLoc, timestampFile);
|
||||
Log.verbose(F("%s DELETED %u" CR), LogLoc, timestampFile);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
Log.error(F("%s delete failed %u - timestampFile %u" CR), LogLoc, timestampFile);
|
||||
Log.error(F("%s FAILED DELETE %u - timestampFile %u" CR), LogLoc, timestampFile);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue