mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-03 11:13:44 +01:00
More polish
This commit is contained in:
1 parent
d2c9104eff
commit
fa64598b4f
4 files changed
+26
-9
No files matched your search
@@ -33,6 +33,7 @@
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/OSD.h"
|
||||
#include "Core/Util/RecentFiles.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Debugger/WebSocket.h"
|
||||
@@ -527,6 +528,18 @@ public:
|
||||
std::lock_guard<std::mutex> guard(g_webServerLock);
|
||||
g_uploadsInProgress.erase(sessionId_);
|
||||
}
|
||||
void SetFile(std::string_view filename, size_t size) {
|
||||
std::lock_guard<std::mutex> guard(g_webServerLock);
|
||||
auto &upload = g_uploadsInProgress[sessionId_];
|
||||
upload.currentFilename = filename;
|
||||
upload.currentFileSize = size;
|
||||
upload.uploadedFiles++;
|
||||
upload.totalBytesBeforeCurrentFile = upload.uploadedBytes;
|
||||
}
|
||||
void AddBytes(size_t bytes) {
|
||||
std::lock_guard<std::mutex> guard(g_webServerLock);
|
||||
g_uploadsInProgress[sessionId_].uploadedBytes += bytes;
|
||||
}
|
||||
private:
|
||||
int sessionId_;
|
||||
};
|
||||
@@ -566,6 +579,8 @@ static MultiPartResult HandleMultipartPart(const http::ServerRequest &request, s
|
||||
} else if (key == "filename") {
|
||||
INFO_LOG(Log::HTTP, "Upload filename: %.*s", STR_VIEW(value));
|
||||
filename = value;
|
||||
} else if (key == "fileSize") {
|
||||
INFO_LOG(Log::HTTP, "Upload filesize: %.*s", STR_VIEW(value));
|
||||
}
|
||||
} else if (equalsNoCase(StripSpaces(part), "Content-Disposition: form-data")) {
|
||||
// this is the first part, ok, ignore.
|
||||
@@ -606,6 +621,7 @@ static MultiPartResult HandleMultipartPart(const http::ServerRequest &request, s
|
||||
}
|
||||
}
|
||||
|
||||
progress.SetFile(filename);
|
||||
u64 bytesTransferred = 0;
|
||||
char buffer[net::InputSink::BUFFER_SIZE];
|
||||
while (true) {
|
||||
@@ -618,6 +634,7 @@ static MultiPartResult HandleMultipartPart(const http::ServerRequest &request, s
|
||||
return MultiPartResult::RequestError;
|
||||
}
|
||||
}
|
||||
progress.AddBytes(readBytes);
|
||||
bytesTransferred += readBytes;
|
||||
if (terminatorFound) {
|
||||
INFO_LOG(Log::HTTP, "Found terminator, skipping and proceeding.");
|
||||
@@ -630,6 +647,8 @@ static MultiPartResult HandleMultipartPart(const http::ServerRequest &request, s
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
g_OSD.Show(OSDType::, StringFromFormat("Uploaded '%s' (%d bytes)", filename.c_str(), (int)bytesTransferred), 5.0f);
|
||||
|
||||
// NOTE: We already read the boundary above.
|
||||
// However if this is the last part, the boundary will have "--\r\n" after it, otherwise there will be a line break.
|
||||
// So, let's read two more bytes, to see if it's "--" or "\r\n".
|
||||
|
||||
+5
-3
@@ -44,9 +44,11 @@ void WebServerSetUploadPath(const Path &path);
|
||||
int WebServerPort();
|
||||
|
||||
struct UploadProgress {
|
||||
size_t uploadedBytes = 0;
|
||||
size_t totalBytes = 0;
|
||||
size_t uploadedFiles = 0; // we don't know the count ahead of time
|
||||
s64 uploadedBytes = 0;
|
||||
s64 totalBytes = 0;
|
||||
s64 uploadedFiles = 0; // we don't know the count ahead of time
|
||||
s64 currentFileSize = 0;
|
||||
s64 totalBytesBeforeCurrentFile = 0;
|
||||
std::string currentFilename;
|
||||
};
|
||||
|
||||
|
||||
+1
-6
@@ -43,16 +43,11 @@ void UploadScreen::CreateViews() {
|
||||
// where files are uploaded sequentially).
|
||||
std::vector<UploadProgress> uploads = GetUploadsInProgress();
|
||||
for (const auto &upload : uploads) {
|
||||
std::string uploadText = StringFromFormat("%zu / %zu bytes uploaded (%zu files). Current file: %s",
|
||||
std::string uploadText = StringFromFormat("%zu / %zu total bytes (%zu files). Current: %s",
|
||||
upload.uploadedBytes, upload.totalBytes, upload.uploadedFiles,
|
||||
upload.currentFilename.c_str());
|
||||
root_->Add(new TextView(uploadText));
|
||||
}
|
||||
|
||||
//infoText->SetTextAlignment(TEXT_ALIGN_CENTER);
|
||||
//verticalLayout->AddView(infoText);
|
||||
//AddStandardBack(verticalLayout);
|
||||
//root_->AddView(verticalLayout);
|
||||
}
|
||||
|
||||
void UploadScreen::update() {
|
||||
|
||||
@@ -252,6 +252,7 @@
|
||||
// Try to preserve any directory structure, if supported.
|
||||
const formData = new FormData();
|
||||
formData.append("file", file, file.webkitRelativePath || file.name);
|
||||
formData.append("fileSize", file.size.toString());
|
||||
xhr.send(formData);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user