File locking and DevelopmentService improvements (#358)
- Moved `file::getlock(path)` from `Tactility` to `TactilityCore` - Changed all existing `file::*` functions to implement locking by default - Removed all manual locking where `file::*` functions were used - When `DevelopmentService` receives a file, it doesn't try to allocate it all in memory. This fixes going out-of-memory on devices without PSRAM. - Fix for TactilityC include
This commit is contained in:
committed by
GitHub
parent
a05a6afaaf
commit
3802679de4
@@ -13,20 +13,8 @@ namespace tt::file {
|
||||
|
||||
/**
|
||||
* @param[in] path the path to find a lock for
|
||||
* @return a non-null lock for the specified path.
|
||||
* @return a lock instance when a lock was found, otherwise nullptr
|
||||
*/
|
||||
std::shared_ptr<Lock> getLock(const std::string& path);
|
||||
|
||||
/**
|
||||
* Acquires a lock, calls the function, then releases the lock.
|
||||
* @param[in] path the path to find a lock for
|
||||
* @param[in] fn the code to execute while the lock is acquired
|
||||
*/
|
||||
template<typename ReturnType>
|
||||
ReturnType withLock(const std::string& path, std::function<ReturnType()> fn) {
|
||||
const auto lock = getLock(path)->asScopedLock();
|
||||
lock.lock();
|
||||
return fn();
|
||||
}
|
||||
std::shared_ptr<Lock> _Nullable findLock(const std::string& path);
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ std::map<std::string, std::string> parseContentDisposition(const std::vector<std
|
||||
|
||||
bool readAndDiscardOrSendError(httpd_req_t* request, const std::string& toRead);
|
||||
|
||||
size_t receiveFile(httpd_req_t* request, size_t length, const std::string& filePath);
|
||||
|
||||
}
|
||||
|
||||
#endif // ESP_PLATFORM
|
||||
Reference in New Issue
Block a user