From 5c1ea70192e8a6d889023373bf66e8cd6c899e1d Mon Sep 17 00:00:00 2001 From: hhchinasoft Date: Tue, 15 Feb 2022 17:34:18 +0800 Subject: [PATCH] bugfix file mode Signed-off-by: hhchinasoft --- frameworks/js/napi/BUILD.gn | 6 ++++++ frameworks/js/napi/src/sendfile.cpp | 4 ++-- interfaces/innerkits/kits/js/@ohos.sendfile.d.ts | 2 +- .../src/device/device_manager_agent.cpp | 7 +++---- .../src/ipc/distributedfile_service.cpp | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn index a34f0a40d..f599bc620 100644 --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -41,6 +41,12 @@ ohos_shared_library("sendfile") { "${distributedfile_path}/frameworks/native/src/filetransfer_callback_stub.cpp", ] + defines = [ + "LOG_TAG=\"distributedfile_napi\"", + "LOG_DOMAIN=0xD001600", + "LOG_LEVEL=INFO", + ] + deps = [ "${distributedfile_path}/interfaces/innerkits/native:libdistributedfile_innerkits", "${utils_path}:libdistributedfileutils", diff --git a/frameworks/js/napi/src/sendfile.cpp b/frameworks/js/napi/src/sendfile.cpp index 4b26aad49..0d1a421f0 100644 --- a/frameworks/js/napi/src/sendfile.cpp +++ b/frameworks/js/napi/src/sendfile.cpp @@ -275,7 +275,7 @@ int32_t NapiWriteFile(int32_t fd, const std::string &fileName) flags |= O_CREAT; } - int32_t writeFd = open(filePath.c_str(), flags, (S_IREAD & S_IWRITE) | S_IRGRP | S_IROTH); + int32_t writeFd = open(filePath.c_str(), flags, (S_IREAD | S_IWRITE) | S_IRGRP | S_IROTH); if (writeFd <= 0) { close(fd); LOGE("NapiWriteFile open file failed %{public}d, %{public}s, %{public}d", writeFd, strerror(errno), errno); @@ -333,7 +333,7 @@ int32_t ExecSendFile(const std::string &deviceId, const std::vector } int32_t fd = open(srcList.at(0).c_str(), O_RDONLY); - int32_t result = distributedFileService->OpenFile(fd, srcList.at(0), (S_IREAD & S_IWRITE) | S_IRGRP | S_IROTH); + int32_t result = distributedFileService->OpenFile(fd, srcList.at(0), (S_IREAD | S_IWRITE) | S_IRGRP | S_IROTH); result = distributedFileService->SendFile(deviceId, srcList, dstList, num); LOGI(" ------------ DistributedFileService SendFile result %{public}d", result); return result; diff --git a/interfaces/innerkits/kits/js/@ohos.sendfile.d.ts b/interfaces/innerkits/kits/js/@ohos.sendfile.d.ts index ef88807e3..8db7b3365 100644 --- a/interfaces/innerkits/kits/js/@ohos.sendfile.d.ts +++ b/interfaces/innerkits/kits/js/@ohos.sendfile.d.ts @@ -18,7 +18,7 @@ import {AsyncCallback, Callback} from "./basic"; * Provides Environment APIs. * * @since 8 - * @sysCap SystemCapability.FileManagement.File.DistributeFile + * @syscap SystemCapability.FileManagement.File.DistributeFile */ declare namespace SendFile { /** diff --git a/services/distributedfileservice/src/device/device_manager_agent.cpp b/services/distributedfileservice/src/device/device_manager_agent.cpp index 11bb75834..2e494cc27 100644 --- a/services/distributedfileservice/src/device/device_manager_agent.cpp +++ b/services/distributedfileservice/src/device/device_manager_agent.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace Storage { namespace DistributedFile { -using namespace std; DeviceManagerAgent::DeviceManagerAgent() {} DeviceManagerAgent::~DeviceManagerAgent() @@ -43,7 +42,7 @@ void DeviceManagerAgent::StopInstance() void DeviceManagerAgent::OnDeviceOnline(const DistributedHardware::DmDeviceInfo &deviceInfo) { - std::unique_lock lock(devsRecordMutex_); + std::unique_lock lock(devsRecordMutex_); std::string cid = std::string(deviceInfo.deviceId); alreadyOnlineDev_.insert(cid); SoftbusAgent::GetInstance()->OnDeviceOnline(cid); @@ -51,7 +50,7 @@ void DeviceManagerAgent::OnDeviceOnline(const DistributedHardware::DmDeviceInfo void DeviceManagerAgent::OnDeviceOffline(const DistributedHardware::DmDeviceInfo &deviceInfo) { - std::unique_lock lock(devsRecordMutex_); + std::unique_lock lock(devsRecordMutex_); std::string cid = std::string(deviceInfo.deviceId); auto softBusAgent = SoftbusAgent::GetInstance(); softBusAgent->OnDeviceOffline(cid); @@ -74,7 +73,7 @@ void DeviceManagerAgent::RegisterToExternalDm() if (errCode != 0) { ThrowException(errCode, "Failed to InitDeviceManager"); } - string extra = ""; + std::string extra = ""; errCode = deviceManager.RegisterDevStateCallback(DistributedFileService::pkgName_, extra, shared_from_this()); if (errCode != 0) { ThrowException(errCode, "Failed to RegisterDevStateCallback"); diff --git a/services/distributedfileservice/src/ipc/distributedfile_service.cpp b/services/distributedfileservice/src/ipc/distributedfile_service.cpp index bdba8d1a1..3683cc7b8 100644 --- a/services/distributedfileservice/src/ipc/distributedfile_service.cpp +++ b/services/distributedfileservice/src/ipc/distributedfile_service.cpp @@ -75,7 +75,7 @@ int32_t DistributedFileService::SendFile(const std::string &cid, const std::vector &destinationFileList, const uint32_t fileCount) { - if (fileCount < 0) { + if (fileCount <= 0) { return -1; } char **sFileList = new char* [fileCount]; @@ -145,7 +145,7 @@ int32_t DistributedFileService::OpenFile(int32_t fd, const std::string &fileName } } - int32_t writeFd = open(tmpFile, O_WRONLY | O_CREAT, (S_IREAD & S_IWRITE) | S_IRGRP | S_IROTH); + int32_t writeFd = open(tmpFile, O_WRONLY | O_CREAT, (S_IREAD | S_IWRITE) | S_IRGRP | S_IROTH); if (writeFd <= 0) { close(fd); LOGE("DFS SA open temp file failed %{public}d, %{public}s, %{public}d", writeFd, strerror(errno), errno); -- Gitee