mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-24 15:27:10 -05:00
A few small fixes and tweaks
This commit is contained in:
parent
2f34ddd3ba
commit
8d988055d7
4
inc/fs.h
4
inc/fs.h
|
|
@ -11,9 +11,9 @@
|
|||
#include "fs/drive.h"
|
||||
#include "ui/miscui.h"
|
||||
|
||||
#define BUFF_SIZE 0x8000
|
||||
#define BUFF_SIZE 0x4000
|
||||
#define ZIP_BUFF_SIZE 0x10000
|
||||
#define TRANSFER_BUFFER_LIMIT 0x600000
|
||||
#define TRANSFER_BUFFER_LIMIT 0xC00000
|
||||
|
||||
namespace fs
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ typedef struct
|
|||
|
||||
static void writeFile_t(void *a)
|
||||
{
|
||||
fsSetPriority(FsPriority_Realtime);
|
||||
fileCpyThreadArgs *in = (fileCpyThreadArgs *)a;
|
||||
size_t written = 0;
|
||||
std::vector<uint8_t> localBuffer;
|
||||
|
|
@ -53,7 +52,6 @@ static void writeFile_t(void *a)
|
|||
|
||||
static void writeFileCommit_t(void *a)
|
||||
{
|
||||
fsSetPriority(FsPriority_Realtime);
|
||||
fileCpyThreadArgs *in = (fileCpyThreadArgs *)a;
|
||||
size_t written = 0, journalCount = 0;
|
||||
std::vector<uint8_t> localBuffer;
|
||||
|
|
@ -213,16 +211,19 @@ void fs::copyFile(const std::string& src, const std::string& dst, threadInfo *t)
|
|||
uint8_t *buff = new uint8_t[BUFF_SIZE];
|
||||
std::vector<uint8_t> transferBuffer;
|
||||
Thread writeThread;
|
||||
threadCreate(&writeThread, writeFile_t, &thrdArgs, NULL, 0x40000, 0x2C, 1);
|
||||
threadCreate(&writeThread, writeFile_t, &thrdArgs, NULL, 0x40000, 0x2E, 1);
|
||||
threadStart(&writeThread);
|
||||
size_t readIn = 0;
|
||||
uint64_t readCount = 0;
|
||||
while((readIn = fread(buff, 1, BUFF_SIZE, fsrc)) > 0)
|
||||
{
|
||||
transferBuffer.insert(transferBuffer.end(), buff, buff + readIn);
|
||||
if(c)
|
||||
c->offset += readIn;
|
||||
readCount += readIn;
|
||||
|
||||
if(transferBuffer.size() > TRANSFER_BUFFER_LIMIT || readIn < BUFF_SIZE)
|
||||
if(c)
|
||||
c->offset = readCount;
|
||||
|
||||
if(transferBuffer.size() >= TRANSFER_BUFFER_LIMIT || readCount == filesize)
|
||||
{
|
||||
std::unique_lock<std::mutex> buffLock(thrdArgs.bufferLock);
|
||||
thrdArgs.cond.wait(buffLock, [&thrdArgs]{ return thrdArgs.bufferIsFull == false; });
|
||||
|
|
@ -290,14 +291,17 @@ void fs::copyFileCommit(const std::string& src, const std::string& dst, const st
|
|||
|
||||
uint8_t *buff = new uint8_t[BUFF_SIZE];
|
||||
size_t readIn = 0;
|
||||
uint64_t readCount = 0;
|
||||
std::vector<uint8_t> transferBuffer;
|
||||
threadStart(&writeThread);
|
||||
while((readIn = fread(buff, 1, BUFF_SIZE, fsrc)) > 0)
|
||||
{
|
||||
transferBuffer.insert(transferBuffer.end(), buff, buff + readIn);
|
||||
readCount += readIn;
|
||||
if(c)
|
||||
c->offset += readIn;
|
||||
if(transferBuffer.size() >= thrdArgs.writeLimit || readIn < BUFF_SIZE)
|
||||
c->offset = readCount;
|
||||
|
||||
if(transferBuffer.size() >= thrdArgs.writeLimit || readCount == filesize)
|
||||
{
|
||||
std::unique_lock<std::mutex> buffLock(thrdArgs.bufferLock);
|
||||
thrdArgs.cond.wait(buffLock, [&thrdArgs]{ return thrdArgs.bufferIsFull == false; });
|
||||
|
|
|
|||
|
|
@ -189,14 +189,16 @@ void fs::copyZipToDir(unzFile src, const std::string& dst, const std::string& de
|
|||
threadStart(&writeThread);
|
||||
|
||||
std::vector<uint8_t> transferBuffer;
|
||||
uint64_t readCount = 0;
|
||||
while((readIn = unzReadCurrentFile(src, buff, BUFF_SIZE)) > 0)
|
||||
{
|
||||
transferBuffer.insert(transferBuffer.end(), buff, buff + readIn);
|
||||
readCount += readIn;
|
||||
|
||||
if(c)
|
||||
c->offset += readIn;
|
||||
|
||||
if(transferBuffer.size() >= unzThrd.writeLimit || readIn < BUFF_SIZE)
|
||||
if(transferBuffer.size() >= unzThrd.writeLimit || readCount == info.uncompressed_size)
|
||||
{
|
||||
std::unique_lock<std::mutex> buffLock(unzThrd.buffLock);
|
||||
unzThrd.cond.wait(buffLock, [&unzThrd]{ return unzThrd.bufferIsFull == false; });
|
||||
|
|
|
|||
10
src/gd.cpp
10
src/gd.cpp
|
|
@ -17,7 +17,7 @@ Still major WIP
|
|||
*/
|
||||
|
||||
#define DRIVE_UPLOAD_BUFFER_SIZE 0x8000
|
||||
#define DRIVE_DOWNLOAD_BUFFER_SIZE 0xA00000
|
||||
#define DRIVE_DOWNLOAD_BUFFER_SIZE 0xC00000
|
||||
#define DRIVE_DEFAULT_PARAMS_AND_QUERY "?fields=files(name,id,mimeType,size,parents)&pageSize=1000&q=trashed=false\%20and\%20\%27me\%27\%20in\%20owners"
|
||||
|
||||
#define tokenURL "https://oauth2.googleapis.com/token"
|
||||
|
|
@ -79,7 +79,7 @@ static size_t writeDataBufferThreaded(uint8_t *buff, size_t sz, size_t cnt, void
|
|||
downloadBuffer.insert(downloadBuffer.end(), buff, buff + (sz * cnt));
|
||||
in->downloaded += sz * cnt;
|
||||
|
||||
if(in->downloaded == in->cfa->size || (downloadBuffer.size() >= DRIVE_DOWNLOAD_BUFFER_SIZE))
|
||||
if(in->downloaded == in->cfa->size || downloadBuffer.size() == DRIVE_DOWNLOAD_BUFFER_SIZE)
|
||||
{
|
||||
std::unique_lock<std::mutex> dataLock(in->dataLock);
|
||||
in->cond.wait(dataLock, [in]{ return in->bufferFull == false; });
|
||||
|
|
@ -668,6 +668,12 @@ void drive::gd::deleteFile(const std::string& _fileID)
|
|||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
int error = curl_easy_perform(curl);
|
||||
|
||||
for(unsigned i = 0; i < driveList.size(); i++)
|
||||
{
|
||||
if(driveList[i].id == _fileID)
|
||||
driveList.erase(driveList.begin() + i);
|
||||
}
|
||||
|
||||
curl_slist_free_all(delHeaders);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ void confirm_t(void *a)
|
|||
break;
|
||||
}
|
||||
|
||||
svcSleepThread(10000000);//Close enough
|
||||
svcSleepThread(1e+9 / 60);//Close enough
|
||||
}
|
||||
delete c;
|
||||
t->finished = true;
|
||||
|
|
@ -488,7 +488,7 @@ static void showMessage_t(void *a)
|
|||
if(ui::padKeysDown() & HidNpadButton_A)
|
||||
break;
|
||||
|
||||
svcSleepThread(10000000);
|
||||
svcSleepThread(1e+9 / 60);
|
||||
}
|
||||
delete text;
|
||||
t->finished = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user