Skip to content

Commit 4f43c34

Browse files
authored
Merge pull request #27 from groot007/dev
Dev
2 parents c19a988 + 36a1124 commit 4f43c34

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flippio",
3-
"version": "0.2.12",
3+
"version": "0.2.13",
44
"description": "Database viewer with device connection",
55
"author": "koliastanis",
66
"homepage": "https://github.com/groot007/flippio",

src/main/ipc/adb.ts

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ async function pullAndroidDBFiles(packageName, deviceId, remotePath, localPath =
3434

3535
// Use run-as to copy the database file to the local machine
3636
await new Promise<void>((resolve, reject) => {
37-
// Use exec-out to avoid text encoding issues with binary data
38-
const adminCmd = location?.admin ? `run-as ${packageName}` : ''
39-
const cmd = `adb -s ${deviceId} exec-out ${adminCmd} cat ${remotePath} > ${localPath}`
40-
exec(cmd, (error, _stdout, stderr) => {
37+
let callCmd = `adb -s ${deviceId} exec-out run-as ${packageName} cat ${remotePath} > ${localPath}`
38+
39+
if (location.admin === false) {
40+
// If not admin, we need to pull the file instead
41+
callCmd = `adb -s ${deviceId} pull ${remotePath} ${localPath}`
42+
}
43+
44+
log.info(`Running command pull: ${callCmd}`)
45+
exec(callCmd, (error, _stdout, _stderr) => {
4146
if (error) {
4247
reject(error)
4348
}
44-
else if (stderr && !stderr.includes('pulled')) {
45-
reject(new Error(stderr))
46-
}
4749
else {
4850
resolve()
4951
}
@@ -203,6 +205,8 @@ export function setupIpcADB() {
203205
const adminCmd = options.admin ? `run-as ${packageName}` : ''
204206
const cmd = `adb -s ${deviceId} shell ${adminCmd} find ${location}${packageName}/ -name "*.db" -o -name "*.sqlite" -o -name "*.sqlite3" 2>/dev/null`
205207

208+
log.info(`Running command: ${cmd}`)
209+
206210
const filesOutput = await new Promise<string>((resolve, _reject) => {
207211
exec(cmd, (_error, stdout, _stderr) => {
208212
// We don't reject here because some errors are expected
@@ -214,21 +218,24 @@ export function setupIpcADB() {
214218
// Process found files
215219
const filePaths = filesOutput.split('\n').filter(line => line.trim().length > 0)
216220

217-
await Promise.all(filePaths.map(async (filePath) => {
218-
const filename = path.basename(filePath)
219-
220-
const pulledFileData = await pullAndroidDBFiles(packageName, deviceId, filePath, '', location)
221-
222-
databaseFiles.push({
223-
path: pulledFileData.path || filePath,
224-
packageName,
225-
filename,
226-
location,
227-
remotePath: filePath,
228-
deviceType: 'android',
229-
})
230-
}),
221+
const pulledFiles = await Promise.all(
222+
filePaths.map(async (filePath) => {
223+
const filename = path.basename(filePath)
224+
225+
const pulledFileData = await pullAndroidDBFiles(packageName, deviceId, filePath, '', location)
226+
227+
return {
228+
path: pulledFileData.path || filePath,
229+
packageName,
230+
filename,
231+
location,
232+
remotePath: filePath,
233+
deviceType: 'android',
234+
} as DatabaseFile
235+
}),
231236
)
237+
238+
databaseFiles.push(...pulledFiles)
232239
}
233240
catch (err) {
234241
// Silently fail for individual locations - we'll still try others
@@ -251,6 +258,21 @@ export function setupIpcADB() {
251258
const filename = path.basename(localPath)
252259
const tmpPath = `/data/local/tmp/${filename}`
253260

261+
if (remotePath.includes('sdcard') || remotePath.includes('external')) {
262+
await new Promise<void>((resolve, reject) => {
263+
exec(`adb -s ${deviceId} push ${localPath} ${remotePath}`, (error, _stdout, _stderr) => {
264+
if (error) {
265+
reject(error)
266+
}
267+
else {
268+
resolve()
269+
}
270+
})
271+
})
272+
273+
return
274+
}
275+
254276
// Push the file to device tmp directory
255277
await new Promise<void>((resolve, reject) => {
256278
exec(`adb -s ${deviceId} push "${localPath}" ${tmpPath}`, (error, _stdout, stderr) => {

src/renderer/src/components/data/DragAndDropProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export const DragAndDropProvider: React.FC<DragAndDropProviderProps> = ({ childr
8989
filename: file.name,
9090
deviceType: 'desktop',
9191
packageName: '',
92+
remotePath: filePath,
9293
})
9394
toaster.create({
9495
title: 'Database opened',

0 commit comments

Comments
 (0)