[DEV] build back
This commit is contained in:
parent
2073938bc5
commit
e4ddecc0eb
@ -71,12 +71,40 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map<
|
||||
}
|
||||
std::string storedSha512;
|
||||
if (etk::FSNodeExist(_path + ".sha512") == true) {
|
||||
//TODO ...
|
||||
storedSha512 = etk::FSNodeReadAllData(_path + ".sha512");
|
||||
uint64_t time_sha512 = etk::FSNodeGetTimeModified(_path + ".sha512");
|
||||
uint64_t time_elem = etk::FSNodeGetTimeModified(_path);
|
||||
std::string storedSha512_file = etk::FSNodeReadAllData(_path + ".sha512");
|
||||
if (time_elem > time_sha512) {
|
||||
// check the current sha512
|
||||
storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path));
|
||||
if (storedSha512_file != storedSha512) {
|
||||
//need to remove the old sha file
|
||||
auto idFileToRemove_fut = _srv.getId(storedSha512_file).waitFor(echrono::seconds(2));
|
||||
if (idFileToRemove_fut.hasError() == true) {
|
||||
APPL_ERROR("can not remove the remote file with sha " + storedSha512_file);
|
||||
} else {
|
||||
APPL_INFO("Remove old deprecated file: " + storedSha512_file);
|
||||
_srv.remove(idFileToRemove_fut.get());
|
||||
// note, no need to wait the call is async ... and the user does not interested with the result ...
|
||||
}
|
||||
}
|
||||
// store new sha512 ==> this update tile too ...
|
||||
etk::FSNodeWriteAllData(_path + ".sha512", storedSha512);
|
||||
} else {
|
||||
// store new sha512
|
||||
storedSha512 = etk::FSNodeReadAllData(_path + ".sha512");
|
||||
}
|
||||
} else {
|
||||
storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path));
|
||||
etk::FSNodeWriteAllData(_path + ".sha512", storedSha512);
|
||||
}
|
||||
// push only if the file exist
|
||||
// TODO : Check the metadata updating ...
|
||||
auto idFile_fut = _srv.getId(storedSha512).waitFor(echrono::seconds(2));
|
||||
if (idFile_fut.hasError() == false) {
|
||||
// media already exit ==> stop here ...
|
||||
return true;
|
||||
}
|
||||
// TODO: Do it better ==> add the calback to know the push progression ...
|
||||
uint32_t mediaId = _srv.add(zeus::File::create(_path, storedSha512)).waitFor(echrono::seconds(20000)).get();
|
||||
if (mediaId == 0) {
|
||||
|
@ -140,6 +140,20 @@ namespace appl {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
uint32_t getId(std::string _sha512) override {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
// TODO : Check right ...
|
||||
uint32_t out;
|
||||
for (size_t iii=0; iii<m_listFile.size(); ++iii) {
|
||||
if (m_listFile[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (m_listFile[iii]->getSha512() == _sha512) {
|
||||
return m_listFile[iii]->getUniqueId();
|
||||
}
|
||||
}
|
||||
throw std::invalid_argument("sha512 not find...");
|
||||
}
|
||||
|
||||
// Return a File Data (might be a video .tiff/.png/.jpg)
|
||||
ememory::SharedPtr<zeus::Media> get(uint32_t _mediaId) override {
|
||||
|
@ -17,6 +17,12 @@ uint32 count()
|
||||
#return:List of the media Ids
|
||||
vector:uint32 getIds(uint32,uint32)
|
||||
|
||||
#brief: Get the Id of the element with the current sha 512
|
||||
#param:sha512:Sha512 of the file searched
|
||||
#return:Id of the media
|
||||
uint32 getId(string)
|
||||
|
||||
|
||||
// ----------------- media Access -----------------------
|
||||
#brief:Get a media
|
||||
#param:mediaId:Id of the media
|
||||
|
@ -37,7 +37,7 @@ bool zeus::checkOrderFunctionParameter() {
|
||||
|
||||
const std::string zeus::g_threadKeyTransactionId("zeus-transaction-id");
|
||||
const std::string zeus::g_threadKeyTransactionSource("zeus-transaction-source");
|
||||
const std::string zeus::g_threadKeyTransactiondestination("zeus-transaction-destination");
|
||||
const std::string zeus::g_threadKeyTransactionDestination("zeus-transaction-destination");
|
||||
|
||||
|
||||
enum zeus::AbstractFunction::type zeus::AbstractFunction::getType() const {
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
|
||||
namespace zeus {
|
||||
static const std::string g_threadKeyTransactionId;
|
||||
static const std::string g_threadKeyTransactionSource;
|
||||
static const std::string g_threadKeyTransactiondestination;
|
||||
extern const std::string g_threadKeyTransactionId;
|
||||
extern const std::string g_threadKeyTransactionSource;
|
||||
extern const std::string g_threadKeyTransactionDestination;
|
||||
/**
|
||||
* @bried check if the compilater order the function element call in order or backOrder
|
||||
*/
|
||||
|
@ -100,7 +100,7 @@ namespace zeus {
|
||||
* @brief Attach callback on activity of the action if user set some return information
|
||||
* @param[in] _callback Handle on the function to call in progress information
|
||||
*/
|
||||
Future<ZEUS_RETURN>& onProgress(ObserverProgress _callback) {
|
||||
Future<ZEUS_RETURN>& onProgress(Promise::ObserverProgress _callback) {
|
||||
zeus::FutureBase::onProgress(_callback);
|
||||
return *this;
|
||||
}
|
||||
@ -190,7 +190,7 @@ namespace zeus {
|
||||
* @brief Attach callback on activity of the action if user set some return information
|
||||
* @param[in] _callback Handle on the function to call in progress information
|
||||
*/
|
||||
Future<void>& onProgress(ObserverProgress _callback) {
|
||||
Future<void>& onProgress(Promise::ObserverProgress _callback) {
|
||||
zeus::FutureBase::onProgress(_callback);
|
||||
return *this;
|
||||
}
|
||||
|
@ -123,7 +123,8 @@ bool zeus::Promise::setMessage(ememory::SharedPtr<zeus::Message> _value) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// notification of a progresion ...
|
||||
if (m_callbackProgress != nullptr) {
|
||||
return m_callbackProgress(_value.);
|
||||
// TODO: return m_callbackProgress(_value.);
|
||||
#warning progress callback to do ..
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace zeus {
|
||||
using Observer = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
|
||||
using ObserverProgress = std::function<void(const std::string&)>; //!< Define the observer on activity of the action (note that is a string, but it can contain json or other ...)
|
||||
private:
|
||||
std::mutex m_mutex; //!< local prevention of multiple acess
|
||||
mutable std::mutex m_mutex; //!< local prevention of multiple acess
|
||||
uint32_t m_transactionId; //!< waiting answer data
|
||||
uint32_t m_source; //!< Source of the message.
|
||||
ememory::SharedPtr<zeus::Message> m_message; //!< all buffer concatenate or last buffer if synchronous
|
||||
|
@ -65,3 +65,4 @@ string getSha512()
|
||||
#brief:Get decorated name of the file
|
||||
#return:decorated name: Name of the file decorated like StarWars-e04-A new Hope(1978).mkv
|
||||
string getDecoratedName()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user