Skip to content

Commit

Permalink
Fix files larger than 4MB, fix top bar coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
dado3212 committed Jul 7, 2024
1 parent 907045d commit e02c23a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
14 changes: 13 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ html {
font-family: 'SF Pro', -apple-system, system-ui, sans-serif;
}

#titlebar {
height: 28px;
line-height: 28px;
font-size: 14px;
text-align: center;
vertical-align: middle;

-webkit-app-region: drag; /* Allow user to drag the window using this titlebar */
-webkit-user-select: none; /* Prevent user from selecting things */
user-select: none;
}

body {
margin: 0px;
display: flex;
Expand Down Expand Up @@ -52,7 +64,7 @@ body {

#content {
display: flex;
height: calc(100% - 51px);
height: calc(100% - 79px);

border-top: 1px solid #eceef0;
}
Expand Down
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-free/css/all.min.css">
</head>
<body>
<div id="titlebar">Books Annotations</div>
<div id="menu">
<div class="devices">
<span>Loading...</span>
Expand Down
3 changes: 3 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const createWindow = () => {
nodeIntegration: true,
contextIsolation: false,
},
titleBarStyle: 'hidden',
});

mainWindow.loadFile('html/index.html');
Expand Down Expand Up @@ -66,6 +67,7 @@ ipcMain.handle('read-plist', async (event, filePath, name) => {
function sendDevice(event) {
let device = deviceManager.getDevice();
if (device == null) {
event.sender.send('debug-log', 'Device is null.');
event.sender.send('device-name', { success: false, message: 'No device found. Please attach device.' });
return;
}
Expand All @@ -87,6 +89,7 @@ function sendDevice(event) {
ipcMain.handle('fetch-devices', async (event) => {
// If it's not ready, then enqueue for after
if (!isDeviceManagerReady) {
event.sender.send('debug-lug', 'Device manager not read yet, will attempt once finished.');
onDeviceManagerReady = () => {
sendDevice(event)
};
Expand Down
5 changes: 4 additions & 1 deletion js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ipcRenderer.on('plist-data', async function (_, info) {
await ipcRenderer.invoke('read-plist', '/Books/com.apple.ibooks-sync.plist', 'annotations');
} else if (info.file == 'annotations') {
let parsed = plist.parse(info.data);

let bookmarks = parsed[Object.keys(parsed)[0]]['Bookmarks'];

bookmarks.forEach(bookmark => {
Expand Down Expand Up @@ -164,6 +163,10 @@ async function populate() {
});
}

ipcRenderer.on('debug-log', function (_, data) {
console.log(data);
});

ipcRenderer.on('error', function (_, error) {
$('.devices span')[0].innerHTML = error;
});
Expand Down
13 changes: 10 additions & 3 deletions libijs/lib/services/afc/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ class File {
debug("readAll: Failed to get file info");
return null;
}
const fileSize = parseInt(fileInfo.st_size, 10);

return yield this.read(fileSize);
let fileSize = parseInt(fileInfo.st_size, 10);
// Reading it all will fail because we can only read 4MB chunks at a time
const chunkSize = 1024 * 1024 * 4; // 4194304 bytes
let bufferChunks = [];
while (fileSize > chunkSize) {
bufferChunks.push(yield this.read(chunkSize));
fileSize -= chunkSize;
}
bufferChunks.push(yield this.read(fileSize));
return Buffer.concat(bufferChunks);
}.bind(this));
}

Expand Down

0 comments on commit e02c23a

Please sign in to comment.