mirror of
https://github.com/ONLYOFFICE/desktop-sdk.git
synced 2026-03-31 10:23:12 +08:00
Fix bug 73852
This commit is contained in:
@ -611,8 +611,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsCopied = false;
|
||||
if (sLocalFilePath != sDestinationPath)
|
||||
{
|
||||
NSFile::CFileBinary::Copy(sLocalFilePath, sDestinationPath);
|
||||
bIsCopied = true;
|
||||
}
|
||||
|
||||
bool bIsTestFile = true;
|
||||
if (!NSFile::CFileBinary::Exists(sDestinationPath))
|
||||
@ -636,6 +640,9 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bIsCopied && (m_oInfo.m_nCurrentFileFormat == AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF || m_oInfo.m_nCurrentFileFormat == AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA))
|
||||
NSSystem::CFileLocker::RemoveRestrictionFlags(sDestinationPath);
|
||||
|
||||
std::wstring sNameInfo = m_oInfo.m_sRecoveryDir + L"/asc_name.info";
|
||||
if (NSFile::CFileBinary::Exists(sNameInfo))
|
||||
NSFile::CFileBinary::Remove(sNameInfo);
|
||||
|
||||
@ -186,6 +186,7 @@ namespace NSSystem
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace NSSystem
|
||||
{
|
||||
@ -536,19 +537,19 @@ namespace NSSystem
|
||||
|
||||
CFileLocker* CFileLocker::Create(const std::wstring& file)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
return new NSSystem::CFileLockerWin(file);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _LINUX
|
||||
#ifndef _MAC
|
||||
#ifdef _LINUX
|
||||
#ifndef _MAC
|
||||
if (IsLocalFile(file))
|
||||
return new NSSystem::CFileLockerFCNTL(file);
|
||||
else
|
||||
return new NSSystem::CFileLockerGIO(file);
|
||||
#else
|
||||
#else
|
||||
return new NSSystem::CFileLockerEmpty(file);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ERROR!!!
|
||||
@ -572,4 +573,42 @@ namespace NSSystem
|
||||
{
|
||||
return CHandlesMonitor::Instance().IsExist(file);
|
||||
}
|
||||
|
||||
bool CFileLocker::RemoveRestrictionFlags(const std::wstring& file)
|
||||
{
|
||||
#ifdef _LINUX
|
||||
std::wstring fileA = U_TO_UTF8(file);
|
||||
struct stat fileStat;
|
||||
if (stat(fileA.c_str, &fileStat) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileStat.st_mode & S_IWUSR)
|
||||
return true;
|
||||
|
||||
if (chmod(filename, fileStat.st_mode | S_IWUSR) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
DWORD attrs = GetFileAttributesW(file.c_str());
|
||||
if (attrs == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 == (attrs & FILE_ATTRIBUTE_READONLY))
|
||||
return true;
|
||||
|
||||
if (!SetFileAttributesW(file.c_str(), attrs &= ~FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +68,8 @@ namespace NSSystem
|
||||
static CFileLocker* Create(const std::wstring& file);
|
||||
|
||||
static bool IsHandled(const std::wstring& file);
|
||||
|
||||
static bool RemoveRestrictionFlags(const std::wstring& file);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user