Hopefully this is a quick one, I know that if i have my spiffs configuration .CSV file in my root and I run “pio run -t uploadfs” my data folder gets packed up and sent to the spiffs file system all nice and tidy, buuuuuut… I want to ideally be able to do it either, whenever I have modified the contents of the data folder or just when I run a code upload get the spiffs stuff sent automatically with the build of code/&/or change to spiffs. I am sure i am just missing an environment setting and I have gone RTFM blind from the past few days of help files and a Happy 4th of July to my 'murican friends.
whenever I have modified the contents of the data folder
Don’t think this is implemented… and would suggest it won’t… as it would require a daemon/watcher to be running the whole time, and some sort of time delay because you don’t want it to be updated twice if you make two edits a few seconds apart (which would then have to be configurable, because how long of a delay is enough or too much?, as well as the feature itself being enabled at all).
just when I run a code upload get the spiffs stuff sent automatically
Don’t know of an option for this, which would be handy. I wonder if it could be added via the extra_scripts functionality?
Here is a nice script to run pre-build. It builds and uploads the data image only when a file has been changed, added, or deleted.
import os
projDirPath = '<your project path>'
dataDirPath = projDirPath + '\\data'
timeFilePath = projDirPath + '\\spiffs-timesum.txt'
if(not os.path.exists(timeFilePath)):
timeFile = open(timeFilePath, "w")
timeFile.write("0.0")
timeFile.close()
timeFile = open(timeFilePath, "r")
oldTime = float(timeFile.read())
timeFile.close()
# print(oldTime)
newTime = float((sum(os.path.getmtime(os.path.join(dataDirPath, file_name)) for file_name in os.listdir(dataDirPath))))
# print(newTime)
if newTime != oldTime:
print("\nfile updated in data directory -- building/uploading spiffs image\n")
os.system('pio run -t uploadfs')
timeFile = open(timeFilePath, "w")
timeFile.write(str(newTime))
timeFile.close()
EDIT: Oops, this uploads the data folder and starts a firmware upload, which then runs this script again in an infinite loop. I’ll have to fix this and edit this script to only upload the data folder. Hold tight …
I have no idea how to run a script automatically before or after a build without this infinite loop problem. I guess I’ll run this in vscode from a shortcut key. I really wanted to do it without thinking when uploading the firmware. Oh well …