Signed-off-by: ml <mengli12@huawei.com>

This commit is contained in:
ml 2024-11-11 15:56:48 +08:00
parent dea495538b
commit d1143623f2
2 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import {
toggleShow,
directionStatus,
getTime,
isValidPath,
sendDlpManagerFileConfiguration
} from '../common/utils';
import { DlpAlertDialog } from '../common/components/dlp_alert_dialog';
@ -216,6 +217,10 @@ struct changeEncryption {
HiLog.info(TAG, `Decrypt DLP file: ${this.srcFileName}`);
try {
let srcFileUri: string = GlobalContext.load('uri');
if (!isValidPath(srcFileUri)) {
HiLog.error(TAG, `uri is invalid`);
return;
}
let srcFileMsg: FileMsg = FileUtils.getAllSuffixByUri(srcFileUri);
let documentSaveOptions = new picker.DocumentSaveOptions();
documentSaveOptions.newFileNames = [decodeURIComponent(plaintextFile)];
@ -245,6 +250,10 @@ struct changeEncryption {
async fileDecryption(saveRes: Array<string>): Promise<void> {
let plainUri = saveRes[0];
if (!isValidPath(plainUri)) {
HiLog.error(TAG, `pick save uri is invalid`);
return;
}
let uriInfo: fileUri.FileUri | undefined = undefined;
let file: fs.File | undefined = undefined;
try {

View File

@ -37,6 +37,7 @@ import {
getFileUriByPath,
sendDlpFileCreateProperties,
sendDlpManagerFileConfiguration,
isValidPath,
getFileSizeByUri
} from '../common/utils';
import Constants from '../common/constant';
@ -366,6 +367,10 @@ struct DlpDialog {
await this.setUserStat();
try {
let srcFileUri: string = GlobalContext.load('uri');
if (!isValidPath(srcFileUri)) {
HiLog.error(TAG, `uri is invalid`);
return;
}
let srcFileMsg: FileMsg = FileUtils.getSuffixFileMsgByUri(srcFileUri);
let srcFileSize: number = await getFileSizeByUri(srcFileUri);
AppStorage.setOrCreate('hiFileSize', srcFileSize);
@ -385,6 +390,10 @@ struct DlpDialog {
}
HiLog.info(TAG, `get uri success`);
uri = saveRes[0];
if (!isValidPath(uri)) {
HiLog.error(TAG, `pick save uri is invalid`);
return;
}
let uriInfo: fileUri.FileUri = new fileUri.FileUri('');
try {
uriInfo = new fileUri.FileUri(uri);