file manager fixes
This commit is contained in:
parent
3a52dfc4ea
commit
8128ac09b3
@ -85,6 +85,9 @@ private:
|
|||||||
void queue_upload(const std::string &api_path, const std::string &source_path,
|
void queue_upload(const std::string &api_path, const std::string &source_path,
|
||||||
bool no_lock);
|
bool no_lock);
|
||||||
|
|
||||||
|
void remove_resume(const std::string &api_path,
|
||||||
|
const std::string &source_path, bool no_lock);
|
||||||
|
|
||||||
void remove_upload(const std::string &api_path, bool no_lock);
|
void remove_upload(const std::string &api_path, bool no_lock);
|
||||||
|
|
||||||
void swap_renamed_items(std::string from_api_path, std::string to_api_path,
|
void swap_renamed_items(std::string from_api_path, std::string to_api_path,
|
||||||
@ -131,13 +134,13 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] auto get_open_handle_count() const -> std::size_t;
|
[[nodiscard]] auto get_open_handle_count() const -> std::size_t;
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto get_stored_downloads() const
|
||||||
get_stored_downloads() const -> std::vector<i_file_mgr_db::resume_entry>;
|
-> std::vector<i_file_mgr_db::resume_entry>;
|
||||||
|
|
||||||
[[nodiscard]] auto has_no_open_file_handles() const -> bool override;
|
[[nodiscard]] auto has_no_open_file_handles() const -> bool override;
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto is_processing(const std::string &api_path) const
|
||||||
is_processing(const std::string &api_path) const -> bool override;
|
-> bool override;
|
||||||
|
|
||||||
#if defined(PROJECT_TESTING)
|
#if defined(PROJECT_TESTING)
|
||||||
[[nodiscard]] auto open(std::shared_ptr<i_closeable_open_file> of,
|
[[nodiscard]] auto open(std::shared_ptr<i_closeable_open_file> of,
|
||||||
@ -150,13 +153,13 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] auto remove_file(const std::string &api_path) -> api_error;
|
[[nodiscard]] auto remove_file(const std::string &api_path) -> api_error;
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto rename_directory(const std::string &from_api_path,
|
||||||
rename_directory(const std::string &from_api_path,
|
const std::string &to_api_path)
|
||||||
const std::string &to_api_path) -> api_error;
|
-> api_error;
|
||||||
|
|
||||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
||||||
const std::string &to_api_path,
|
const std::string &to_api_path, bool overwrite)
|
||||||
bool overwrite) -> api_error;
|
-> api_error;
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
@ -29,14 +29,14 @@ class i_upload_manager {
|
|||||||
INTERFACE_SETUP(i_upload_manager);
|
INTERFACE_SETUP(i_upload_manager);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void queue_upload(const i_open_file &o) = 0;
|
virtual void queue_upload(const i_open_file &file) = 0;
|
||||||
|
|
||||||
virtual void remove_resume(const std::string &api_path,
|
virtual void remove_resume(const std::string &api_path,
|
||||||
const std::string &source_path) = 0;
|
const std::string &source_path) = 0;
|
||||||
|
|
||||||
virtual void remove_upload(const std::string &api_path) = 0;
|
virtual void remove_upload(const std::string &api_path) = 0;
|
||||||
|
|
||||||
virtual void store_resume(const i_open_file &o) = 0;
|
virtual void store_resume(const i_open_file &file) = 0;
|
||||||
};
|
};
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ void file_manager::queue_upload(const std::string &api_path,
|
|||||||
api_path,
|
api_path,
|
||||||
source_path,
|
source_path,
|
||||||
})) {
|
})) {
|
||||||
remove_resume(api_path, source_path);
|
remove_resume(api_path, source_path, true);
|
||||||
event_system::instance().raise<file_upload_queued>(api_path, source_path);
|
event_system::instance().raise<file_upload_queued>(api_path, source_path);
|
||||||
} else {
|
} else {
|
||||||
event_system::instance().raise<file_upload_failed>(
|
event_system::instance().raise<file_upload_failed>(
|
||||||
@ -454,8 +454,10 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
|
|||||||
|
|
||||||
close_all(api_path);
|
close_all(api_path);
|
||||||
|
|
||||||
|
mutex_lock lock(upload_mtx_);
|
||||||
remove_upload(api_path, true);
|
remove_upload(api_path, true);
|
||||||
remove_resume(api_path, fsi.source_path);
|
remove_resume(api_path, fsi.source_path, true);
|
||||||
|
upload_notify_.notify_all();
|
||||||
|
|
||||||
res = provider_.remove_file(api_path);
|
res = provider_.remove_file(api_path);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -473,12 +475,26 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
|
|||||||
|
|
||||||
void file_manager::remove_resume(const std::string &api_path,
|
void file_manager::remove_resume(const std::string &api_path,
|
||||||
const std::string &source_path) {
|
const std::string &source_path) {
|
||||||
if (not mgr_db_->remove_resume(api_path)) {
|
return remove_resume(api_path, source_path, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void file_manager::remove_resume(const std::string &api_path,
|
||||||
|
const std::string &source_path, bool no_lock) {
|
||||||
|
if (provider_.is_read_only()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<mutex_lock> lock;
|
||||||
|
if (not no_lock) {
|
||||||
|
lock = std::make_unique<mutex_lock>(upload_mtx_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mgr_db_->remove_resume(api_path)) {
|
||||||
event_system::instance().raise<download_resume_removed>(api_path,
|
event_system::instance().raise<download_resume_removed>(api_path,
|
||||||
source_path);
|
source_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_notify_.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::remove_upload(const std::string &api_path) {
|
void file_manager::remove_upload(const std::string &api_path) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user