Skip to content

Commit

Permalink
Merge pull request #7713 from nextcloud/bugfix/doNotAlwaysFreeUpStora…
Browse files Browse the repository at this point in the history
…geWindowsShortcuts

Bugfix/do not always free up storage windows shortcuts
  • Loading branch information
mgallien authored Jan 3, 2025
2 parents 1e91c0e + 6f8a40f commit a25dc6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,8 @@ void ProcessDirectoryJob::processFileFinalize(
if (_discoveryData->_syncOptions._vfs &&
(item->_type == CSyncEnums::ItemTypeFile || item->_type == CSyncEnums::ItemTypeDirectory) &&
item->_instruction == CSyncEnums::CSYNC_INSTRUCTION_NONE &&
FileSystem::isLnkFile((_discoveryData->_localDir + path._local))) {
FileSystem::isLnkFile((_discoveryData->_localDir + path._local)) &&
!_discoveryData->_syncOptions._vfs->isPlaceHolderInSync(_discoveryData->_localDir + path._local)) {
item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_SYNC;
item->_direction = SyncFileItem::Down;
item->_type = CSyncEnums::ItemTypeVirtualFileDehydration;
Expand Down Expand Up @@ -2204,20 +2205,24 @@ void ProcessDirectoryJob::setupDbPinStateActions(SyncJournalFileRecord &record)
{
// Only suffix-vfs uses the db for pin states.
// Other plugins will set localEntry._type according to the file's pin state.
if (!isVfsWithSuffix())
if (!isVfsWithSuffix()) {
return;
}

auto pin = _discoveryData->_statedb->internalPinStates().rawForPath(record._path);
if (!pin || *pin == PinState::Inherited)
if (!pin || *pin == PinState::Inherited) {
pin = _pinState;
}

// OnlineOnly hydrated files want to be dehydrated
if (record._type == ItemTypeFile && *pin == PinState::OnlineOnly)
if (record._type == ItemTypeFile && *pin == PinState::OnlineOnly) {
record._type = ItemTypeVirtualFileDehydration;
}

// AlwaysLocal dehydrated files want to be hydrated
if (record._type == ItemTypeVirtualFile && *pin == PinState::AlwaysLocal)
if (record._type == ItemTypeVirtualFile && *pin == PinState::AlwaysLocal) {
record._type = ItemTypeVirtualFileDownload;
}
}

}
2 changes: 1 addition & 1 deletion src/libsync/propagatorjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void PropagateLocalRemove::start()

QString removeError;
const auto availability = propagator()->syncOptions()._vfs->availability(_item->_file, Vfs::AvailabilityRecursivity::RecursiveAvailability);
if (_moveToTrash && (!availability || (*availability != VfsItemAvailability::AllDehydrated && *availability != VfsItemAvailability::OnlineOnly && *availability != VfsItemAvailability::Mixed))) {
if (_moveToTrash && propagator()->syncOptions()._vfs->mode() != OCC::Vfs::WindowsCfApi) {
if ((QDir(filename).exists() || FileSystem::fileExists(filename))
&& !FileSystem::moveToTrash(filename, &removeError)) {
done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);
Expand Down

0 comments on commit a25dc6a

Please sign in to comment.