-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KDESKTOP-1262] Do not force file status after an upload session abortion #366
base: develop
Are you sure you want to change the base?
Changes from all commits
bb2ee0d
2b78295
dfef0d6
52867f9
677f9d0
87090d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,5 +245,4 @@ bool isLocked(const SyncPath &path) { | |
return isLocked; | ||
} | ||
|
||
|
||
} // namespace KDC |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
*/ | ||
|
||
#include "driveuploadsession.h" | ||
#include "libcommonserver/io/fileAttributes.h" | ||
#include "libcommonserver/io/iohelper.h" | ||
#include "utility/utility.h" | ||
|
||
namespace KDC { | ||
|
@@ -30,15 +32,15 @@ DriveUploadSession::DriveUploadSession(int driveDbId, std::shared_ptr<SyncDb> sy | |
DriveUploadSession::DriveUploadSession(int driveDbId, std::shared_ptr<SyncDb> syncDb, const SyncPath &filepath, | ||
const SyncName &filename, const NodeId &remoteParentDirId, SyncTime modtime, | ||
bool liteSyncActivated, uint64_t nbParalleleThread /*= 1*/) : | ||
AbstractUploadSession(filepath, filename, nbParalleleThread), _driveDbId(driveDbId), _syncDb(syncDb), _modtimeIn(modtime), | ||
_remoteParentDirId(remoteParentDirId) { | ||
AbstractUploadSession(filepath, filename, nbParalleleThread), | ||
_driveDbId(driveDbId), _syncDb(syncDb), _modtimeIn(modtime), _remoteParentDirId(remoteParentDirId) { | ||
(void) liteSyncActivated; | ||
_uploadSessionType = UploadSessionType::Drive; | ||
} | ||
|
||
DriveUploadSession::~DriveUploadSession() { | ||
if (_vfsForceStatus && !_vfsForceStatus(getFilePath(), false, 100, true)) { | ||
LOGW_WARN(getLogger(), L"Error in vfsForceStatus: " << Utility::formatSyncPath(getFilePath()).c_str()); | ||
LOGW_WARN(getLogger(), L"Error in vfsForceStatus: " << Utility::formatSyncPath(getFilePath())); | ||
} | ||
} | ||
|
||
|
@@ -109,4 +111,27 @@ bool DriveUploadSession::handleCancelJobResult(const std::shared_ptr<UploadSessi | |
|
||
return true; | ||
} | ||
|
||
void DriveUploadSession::abort() { | ||
AbstractUploadSession::abort(); | ||
setVfsForceStatusCallback(nullptr); | ||
|
||
#ifdef __APPLE__ | ||
// Removing all extended attributes so that the file that failed to be uploaded is not identified as a dehydrated placeholder | ||
// by the application when restarting the synchronization. | ||
|
||
const SyncPath &localPath = getFilePath(); | ||
static const std::vector<const char *> extendedAttributes = {EXT_ATTR_STATUS, EXT_ATTR_PIN_STATE}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new function IoHelper::removeLiteSyncXAttrs |
||
|
||
for (const auto attribute: extendedAttributes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Questions.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A file is a placeholder if it has the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe. Perhaps we lose permissions during upload, which caused the abort. So the status has been set but cannot be removed, meaning that the file could be dehydrated while not synced, therefor corrupted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe again ^^ but what can we do if the access rights have been removed 🥲
Comment on lines
+124
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be in a utility function outside this class. Especially because |
||
if (auto ioError = IoError::Success; | ||
!IoHelper::removeXAttr(localPath, attribute, ioError) || ioError != IoError::NoSuchFileOrDirectory) { | ||
LOGW_WARN(getLogger(), L"Error in IoHelper::removeXAttr with extended attribute " | ||
<< L"'" << Utility::s2ws(attribute) << L"': " | ||
<< Utility::formatIoError(localPath, ioError)); | ||
} | ||
} | ||
#endif | ||
} | ||
|
||
} // namespace KDC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the common declarations in vfs.h ?
Or create a new dynamic library "libcommonserverext" with the common code.