2013-10-03 13:27:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
2017-09-01 16:11:43 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-10-03 13:27:29 +00:00
|
|
|
*
|
2017-09-01 16:11:43 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2013-10-03 13:27:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SYNCJOURNALFILERECORD_H
|
|
|
|
#define SYNCJOURNALFILERECORD_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
2017-12-14 14:08:53 +00:00
|
|
|
#include "csync.h"
|
2017-09-01 16:11:43 +00:00
|
|
|
#include "ocsynclib.h"
|
2017-09-19 08:53:51 +00:00
|
|
|
#include "remotepermissions.h"
|
2017-09-14 13:50:13 +00:00
|
|
|
#include "common/utility.h"
|
2014-09-26 08:07:17 +00:00
|
|
|
|
2014-11-09 21:34:07 +00:00
|
|
|
namespace OCC {
|
2013-10-03 13:27:29 +00:00
|
|
|
|
2013-10-03 18:00:58 +00:00
|
|
|
class SyncFileItem;
|
|
|
|
|
2022-04-08 08:23:50 +00:00
|
|
|
struct SyncJournalFileLockInfo {
|
|
|
|
bool _locked = false;
|
|
|
|
QString _lockOwnerDisplayName;
|
|
|
|
QString _lockOwnerId;
|
|
|
|
qint64 _lockOwnerType = 0;
|
|
|
|
QString _lockEditorApp;
|
|
|
|
qint64 _lockTime = 0;
|
|
|
|
qint64 _lockTimeout = 0;
|
|
|
|
};
|
|
|
|
|
2015-06-29 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* @brief The SyncJournalFileRecord class
|
|
|
|
* @ingroup libsync
|
2015-06-26 15:07:47 +00:00
|
|
|
*/
|
2017-09-01 16:11:43 +00:00
|
|
|
class OCSYNC_EXPORT SyncJournalFileRecord
|
2013-10-03 13:27:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] bool isValid() const
|
2013-10-03 13:27:29 +00:00
|
|
|
{
|
|
|
|
return !_path.isEmpty();
|
|
|
|
}
|
|
|
|
|
2017-05-10 07:37:10 +00:00
|
|
|
/** Returns the numeric part of the full id in _fileId.
|
|
|
|
*
|
|
|
|
* On the server this is sometimes known as the internal file id.
|
|
|
|
*
|
|
|
|
* It is used in the construction of private links.
|
|
|
|
*/
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] QByteArray numericFileId() const;
|
|
|
|
[[nodiscard]] QDateTime modDateTime() const { return Utility::qDateTimeFromTime_t(_modtime); }
|
2017-05-10 07:37:10 +00:00
|
|
|
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] bool isDirectory() const { return _type == ItemTypeDirectory; }
|
|
|
|
[[nodiscard]] bool isFile() const { return _type == ItemTypeFile || _type == ItemTypeVirtualFileDehydration; }
|
|
|
|
[[nodiscard]] bool isVirtualFile() const { return _type == ItemTypeVirtualFile || _type == ItemTypeVirtualFileDownload; }
|
|
|
|
[[nodiscard]] QString path() const { return QString::fromUtf8(_path); }
|
|
|
|
[[nodiscard]] QString e2eMangledName() const { return QString::fromUtf8(_e2eMangledName); }
|
2018-10-19 12:40:39 +00:00
|
|
|
|
2017-09-14 13:50:13 +00:00
|
|
|
QByteArray _path;
|
2020-05-28 14:59:24 +00:00
|
|
|
quint64 _inode = 0;
|
|
|
|
qint64 _modtime = 0;
|
|
|
|
ItemType _type = ItemTypeSkip;
|
2014-06-19 12:27:04 +00:00
|
|
|
QByteArray _etag;
|
|
|
|
QByteArray _fileId;
|
2020-05-28 14:59:24 +00:00
|
|
|
qint64 _fileSize = 0;
|
2017-09-19 08:53:51 +00:00
|
|
|
RemotePermissions _remotePerm;
|
2020-05-28 14:59:24 +00:00
|
|
|
bool _serverHasIgnoredFiles = false;
|
2017-06-14 10:14:46 +00:00
|
|
|
QByteArray _checksumHeader;
|
2018-02-12 11:50:51 +00:00
|
|
|
QByteArray _e2eMangledName;
|
2020-07-02 15:22:43 +00:00
|
|
|
bool _isE2eEncrypted = false;
|
2022-04-08 08:23:50 +00:00
|
|
|
SyncJournalFileLockInfo _lockstate;
|
2022-09-02 09:48:52 +00:00
|
|
|
bool _isShared = false;
|
|
|
|
qint64 _lastShareStateFetchedTimestmap = 0;
|
2013-10-03 13:27:29 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 16:11:43 +00:00
|
|
|
bool OCSYNC_EXPORT
|
2014-11-19 13:14:54 +00:00
|
|
|
operator==(const SyncJournalFileRecord &lhs,
|
|
|
|
const SyncJournalFileRecord &rhs);
|
2014-10-23 13:15:47 +00:00
|
|
|
|
2017-09-01 16:11:43 +00:00
|
|
|
class OCSYNC_EXPORT SyncJournalErrorBlacklistRecord
|
2013-11-20 12:44:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-07-07 13:11:00 +00:00
|
|
|
enum Category {
|
|
|
|
/// Normal errors have no special behavior
|
|
|
|
Normal = 0,
|
|
|
|
/// These get a special summary message
|
|
|
|
InsufficientRemoteStorage
|
|
|
|
};
|
|
|
|
|
2014-10-09 12:49:51 +00:00
|
|
|
/// The number of times the operation was unsuccessful so far.
|
2020-05-20 23:41:33 +00:00
|
|
|
int _retryCount = 0;
|
2014-10-09 12:49:51 +00:00
|
|
|
|
|
|
|
/// The last error string.
|
2013-11-20 12:44:01 +00:00
|
|
|
QString _errorString;
|
2017-07-07 13:11:00 +00:00
|
|
|
/// The error category. Sometimes used for special actions.
|
2020-05-20 23:41:33 +00:00
|
|
|
Category _errorCategory = Category::Normal;
|
2014-10-09 12:49:51 +00:00
|
|
|
|
2020-05-20 23:41:33 +00:00
|
|
|
qint64 _lastTryModtime = 0;
|
2013-11-20 12:44:01 +00:00
|
|
|
QByteArray _lastTryEtag;
|
2014-10-09 12:49:51 +00:00
|
|
|
|
|
|
|
/// The last time the operation was attempted (in s since epoch).
|
2020-05-20 23:41:33 +00:00
|
|
|
qint64 _lastTryTime = 0;
|
2014-10-09 12:49:51 +00:00
|
|
|
|
|
|
|
/// The number of seconds the file shall be ignored.
|
2020-05-20 23:41:33 +00:00
|
|
|
qint64 _ignoreDuration = 0;
|
2014-10-09 12:49:51 +00:00
|
|
|
|
2013-11-20 12:44:01 +00:00
|
|
|
QString _file;
|
2016-05-25 13:01:26 +00:00
|
|
|
QString _renameTarget;
|
2013-11-20 12:44:01 +00:00
|
|
|
|
2018-04-04 14:27:08 +00:00
|
|
|
/// The last X-Request-ID of the request that failled
|
|
|
|
QByteArray _requestId;
|
|
|
|
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] bool isValid() const;
|
2013-11-20 12:44:01 +00:00
|
|
|
};
|
2017-12-02 10:40:43 +00:00
|
|
|
|
|
|
|
/** Represents a conflict in the conflicts table.
|
|
|
|
*
|
2018-03-28 12:37:21 +00:00
|
|
|
* In the following the "conflict file" is the file that has the conflict
|
|
|
|
* tag in the filename, and the base file is the file that it's a conflict for.
|
|
|
|
* So if "a/foo.txt" is the base file, its conflict file could be
|
|
|
|
* "a/foo (conflicted copy 1234).txt".
|
2017-12-02 10:40:43 +00:00
|
|
|
*/
|
|
|
|
class OCSYNC_EXPORT ConflictRecord
|
|
|
|
{
|
|
|
|
public:
|
2018-03-28 12:37:21 +00:00
|
|
|
/** Path to the file with the conflict tag in the name
|
2017-12-02 10:40:43 +00:00
|
|
|
*
|
|
|
|
* The path is sync-folder relative.
|
|
|
|
*/
|
|
|
|
QByteArray path;
|
|
|
|
|
|
|
|
/// File id of the base file
|
|
|
|
QByteArray baseFileId;
|
|
|
|
|
|
|
|
/** Modtime of the base file
|
|
|
|
*
|
|
|
|
* may not be available and be -1
|
|
|
|
*/
|
|
|
|
qint64 baseModtime = -1;
|
|
|
|
|
|
|
|
/** Etag of the base file
|
|
|
|
*
|
|
|
|
* may not be available and empty
|
|
|
|
*/
|
|
|
|
QByteArray baseEtag;
|
|
|
|
|
2018-08-14 11:35:04 +00:00
|
|
|
/**
|
2018-08-21 09:24:45 +00:00
|
|
|
* The path of the original file at the time the conflict was created
|
|
|
|
*
|
|
|
|
* Note that in nearly all cases one should query the db by baseFileId and
|
|
|
|
* thus retrieve the *current* base path instead!
|
2018-08-14 11:35:04 +00:00
|
|
|
*
|
|
|
|
* maybe be empty if not available
|
|
|
|
*/
|
2018-08-21 09:24:45 +00:00
|
|
|
QByteArray initialBasePath;
|
2018-08-14 11:35:04 +00:00
|
|
|
|
|
|
|
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] bool isValid() const { return !path.isEmpty(); }
|
2017-12-02 10:40:43 +00:00
|
|
|
};
|
2013-10-03 13:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SYNCJOURNALFILERECORD_H
|