Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
7b75a99b
authored
May 08, 2024
by
heheer
Committed by
GitHub
May 08, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add pptx encoding try catch (#1393)
parent
2e468fc8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
packages/service/common/buffer/rawText/schema.ts
+2
-2
packages/service/common/file/gridfs/controller.ts
+3
-3
packages/service/worker/file/parseOffice.ts
+16
-6
No files found.
packages/service/common/buffer/rawText/schema.ts
View file @
7b75a99b
...
...
@@ -28,6 +28,6 @@ try {
console
.
log
(
error
);
}
export
const
MongoR
wa
TextBuffer
:
Model
<
RawTextBufferSchemaType
>
=
export
const
MongoR
aw
TextBuffer
:
Model
<
RawTextBufferSchemaType
>
=
models
[
collectionName
]
||
model
(
collectionName
,
RawTextBufferSchema
);
MongoR
wa
TextBuffer
.
syncIndexes
();
MongoR
aw
TextBuffer
.
syncIndexes
();
packages/service/common/file/gridfs/controller.ts
View file @
7b75a99b
...
...
@@ -6,7 +6,7 @@ import { DatasetFileSchema } from '@fastgpt/global/core/dataset/type';
import
{
MongoFileSchema
}
from
'./schema'
;
import
{
detectFileEncoding
}
from
'@fastgpt/global/common/file/tools'
;
import
{
CommonErrEnum
}
from
'@fastgpt/global/common/error/code/common'
;
import
{
MongoR
wa
TextBuffer
}
from
'../../buffer/rawText/schema'
;
import
{
MongoR
aw
TextBuffer
}
from
'../../buffer/rawText/schema'
;
import
{
readFileRawContent
}
from
'../read/utils'
;
import
{
PassThrough
}
from
'stream'
;
...
...
@@ -162,7 +162,7 @@ export const readFileContentFromMongo = async ({
filename
:
string
;
}
>
=>
{
// read buffer
const
fileBuffer
=
await
MongoR
wa
TextBuffer
.
findOne
({
sourceId
:
fileId
}).
lean
();
const
fileBuffer
=
await
MongoR
aw
TextBuffer
.
findOne
({
sourceId
:
fileId
}).
lean
();
if
(
fileBuffer
)
{
return
{
rawText
:
fileBuffer
.
rawText
,
...
...
@@ -208,7 +208,7 @@ export const readFileContentFromMongo = async ({
});
if
(
rawText
.
trim
())
{
MongoR
wa
TextBuffer
.
create
({
MongoR
aw
TextBuffer
.
create
({
sourceId
:
fileId
,
rawText
,
metadata
:
{
...
...
packages/service/worker/file/parseOffice.ts
View file @
7b75a99b
...
...
@@ -44,9 +44,13 @@ const parsePowerPoint = async ({
}
// Returning an array of all the xml contents read using fs.readFileSync
const
xmlContentArray
=
files
.
map
((
file
)
=>
fs
.
readFileSync
(
`
${
decompressPath
}
/
${
file
.
path
}
`
,
encoding
)
);
const
xmlContentArray
=
files
.
map
((
file
)
=>
{
try
{
return
fs
.
readFileSync
(
`
${
decompressPath
}
/
${
file
.
path
}
`
,
encoding
);
}
catch
(
err
)
{
return
fs
.
readFileSync
(
`
${
decompressPath
}
/
${
file
.
path
}
`
,
'utf-8'
);
}
});
let
responseArr
:
string
[]
=
[];
...
...
@@ -95,9 +99,15 @@ export const parseOffice = async ({
// const decompressPath = `${DEFAULTDECOMPRESSSUBLOCATION}/test`;
// write new file
fs
.
writeFileSync
(
filepath
,
buffer
,
{
encoding
});
try
{
fs
.
writeFileSync
(
filepath
,
buffer
,
{
encoding
});
}
catch
(
err
)
{
fs
.
writeFileSync
(
filepath
,
buffer
,
{
encoding
:
'utf-8'
});
}
const
text
=
await
(
async
()
=>
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment