mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
preserve file modes for up- and downloads - fixes #4141
This commit is contained in:
@@ -205,7 +205,7 @@ export class ElectronPlatformService extends PlatformService {
|
||||
}))
|
||||
}
|
||||
|
||||
async startDownload (name: string, size: number): Promise<FileDownload|null> {
|
||||
async startDownload (name: string, mode: number, size: number): Promise<FileDownload|null> {
|
||||
const result = await this.electron.dialog.showSaveDialog(
|
||||
this.hostWindow.getWindow(),
|
||||
{
|
||||
@@ -215,7 +215,7 @@ export class ElectronPlatformService extends PlatformService {
|
||||
if (!result.filePath) {
|
||||
return null
|
||||
}
|
||||
const transfer = new ElectronFileDownload(result.filePath, size)
|
||||
const transfer = new ElectronFileDownload(result.filePath, mode, size)
|
||||
await wrapPromise(this.zone, transfer.open())
|
||||
this.fileTransferStarted.next(transfer)
|
||||
return transfer
|
||||
@@ -230,6 +230,7 @@ export class ElectronPlatformService extends PlatformService {
|
||||
|
||||
class ElectronFileUpload extends FileUpload {
|
||||
private size: number
|
||||
private mode: number
|
||||
private file: fs.FileHandle
|
||||
private buffer: Buffer
|
||||
|
||||
@@ -239,7 +240,9 @@ class ElectronFileUpload extends FileUpload {
|
||||
}
|
||||
|
||||
async open (): Promise<void> {
|
||||
this.size = (await fs.stat(this.filePath)).size
|
||||
const stat = await fs.stat(this.filePath)
|
||||
this.size = stat.size
|
||||
this.mode = stat.mode
|
||||
this.file = await fs.open(this.filePath, 'r')
|
||||
}
|
||||
|
||||
@@ -247,6 +250,10 @@ class ElectronFileUpload extends FileUpload {
|
||||
return path.basename(this.filePath)
|
||||
}
|
||||
|
||||
getMode (): number {
|
||||
return this.mode
|
||||
}
|
||||
|
||||
getSize (): number {
|
||||
return this.size
|
||||
}
|
||||
@@ -267,19 +274,24 @@ class ElectronFileDownload extends FileDownload {
|
||||
|
||||
constructor (
|
||||
private filePath: string,
|
||||
private mode: number,
|
||||
private size: number,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
|
||||
async open (): Promise<void> {
|
||||
this.file = await fs.open(this.filePath, 'w')
|
||||
this.file = await fs.open(this.filePath, 'w', this.mode)
|
||||
}
|
||||
|
||||
getName (): string {
|
||||
return path.basename(this.filePath)
|
||||
}
|
||||
|
||||
getMode (): number {
|
||||
return this.mode
|
||||
}
|
||||
|
||||
getSize (): number {
|
||||
return this.size
|
||||
}
|
||||
|
Reference in New Issue
Block a user