Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
389e868
Activate github/workflow
zephyranthes03 Sep 5, 2025
7be0539
Update fmt update
zephyranthes03 Sep 8, 2025
53a7e93
Fix import path from src/bin/rabbit_consumer.rs
zephyranthes03 Sep 8, 2025
539e1a9
Remove crashed marker/Merge import block
zephyranthes03 Sep 8, 2025
ce980ac
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 8, 2025
fb632e8
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 8, 2025
f63361a
Bypass rabbit_consumer code
zephyranthes03 Sep 8, 2025
a53a060
Bypass rabbit_consumer code
zephyranthes03 Sep 8, 2025
e0fa20c
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 8, 2025
fc73fdd
Bypass rabbit_consumer code
zephyranthes03 Sep 8, 2025
12362cf
Update deploy procss
zephyranthes03 Sep 9, 2025
5fdd399
Update cosmic-sync-server health check
zephyranthes03 Sep 9, 2025
f19203b
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 9, 2025
6c879dc
Update cosmic-sync-server health check
zephyranthes03 Sep 9, 2025
1982e98
Update cosmic-sync-server health check
zephyranthes03 Sep 9, 2025
53745b6
Update service loading delay/ Update related service env
zephyranthes03 Sep 10, 2025
c55d84a
Fix build error
zephyranthes03 Sep 10, 2025
a43b5ac
Fix build error
zephyranthes03 Sep 10, 2025
15555aa
Update builder rs
zephyranthes03 Sep 10, 2025
37bc15c
Fix static library issue
zephyranthes03 Sep 10, 2025
987a6a9
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 10, 2025
7cdfe0e
Fix static library issue
zephyranthes03 Sep 10, 2025
12aa27f
Fix static library issue
zephyranthes03 Sep 10, 2025
d015f08
Fix static library issue
zephyranthes03 Sep 10, 2025
53c4809
Update secret location
zephyranthes03 Sep 11, 2025
3c1633f
Check system76/cosmic-sync-server repo
zephyranthes03 Sep 11, 2025
65174ca
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 11, 2025
ea38129
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 11, 2025
51c9b41
Check system76/cosmic-sync-server repo
zephyranthes03 Sep 11, 2025
f66baea
Fix Migration issue
zephyranthes03 Sep 12, 2025
c9b0ce4
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 12, 2025
9134c3c
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 12, 2025
cb41ab1
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 12, 2025
69c18c2
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 12, 2025
7a0ba3a
Fix Migration issue
zephyranthes03 Sep 12, 2025
5c7c781
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 12, 2025
00e2616
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 12, 2025
7b8f4ea
Fix Migration issue
zephyranthes03 Sep 13, 2025
77a767c
Update schema
zephyranthes03 Sep 14, 2025
b34ecc4
git Merge branch 'staging' of github.com:system76/cosmic-sync-server …
zephyranthes03 Sep 14, 2025
c8693d0
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 14, 2025
32dd2c7
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 15, 2025
da1dd7a
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 15, 2025
26bd72b
Fix grpc port connection
zephyranthes03 Sep 15, 2025
d03e4b8
Fix grpc port connection
zephyranthes03 Sep 15, 2025
cb2b8ca
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 15, 2025
f80a24b
Fix grpc port connection
zephyranthes03 Sep 15, 2025
1a07741
git Merge branch 'staging' of github.com:system76/cosmic-sync-server …
zephyranthes03 Sep 15, 2025
7e5baae
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 15, 2025
fb16db2
Fix grpc port connection
zephyranthes03 Sep 15, 2025
477969d
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 15, 2025
1cb4790
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 15, 2025
70f649c
Fix grpc port connection
zephyranthes03 Sep 15, 2025
44f5356
git Merge branch 'staging' of github.com:system76/cosmic-sync-server …
zephyranthes03 Sep 15, 2025
6cff219
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 15, 2025
beafa61
Fix grpc port connection
zephyranthes03 Sep 15, 2025
e7c62fd
Fix grpc port connection
zephyranthes03 Sep 15, 2025
c1d2bc1
Update login process - fix OAUTH infos
zephyranthes03 Sep 19, 2025
3f7b8e0
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 19, 2025
0f2edfd
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 19, 2025
c879fa1
Update login process - fix OAUTH infos
zephyranthes03 Sep 22, 2025
e14710e
Update login process - fix saving auth token
zephyranthes03 Sep 22, 2025
22fe3c8
Merge 443/50051
zephyranthes03 Sep 23, 2025
cae291a
Merge 443/50051
zephyranthes03 Sep 23, 2025
e55115d
Merge 443/50051
zephyranthes03 Sep 24, 2025
00ea3ef
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 24, 2025
1b86395
Merge 443/50051
zephyranthes03 Sep 24, 2025
4b8668a
Merge 443/50051
zephyranthes03 Sep 24, 2025
b05e032
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 24, 2025
24056be
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 24, 2025
c193115
Merge 443/50051
zephyranthes03 Sep 24, 2025
f85eae7
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 24, 2025
d1569a8
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 24, 2025
a035a88
Merge 443/50051
zephyranthes03 Sep 24, 2025
509b93c
Fix http size issue
zephyranthes03 Sep 26, 2025
bda4115
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 26, 2025
1dac212
Fix http size issue
zephyranthes03 Sep 26, 2025
18f0f72
Fix http size issue
zephyranthes03 Sep 26, 2025
2b6c550
Fix http size issue
zephyranthes03 Sep 26, 2025
ad42771
Fix http size issue
zephyranthes03 Sep 26, 2025
98dafbe
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 26, 2025
c652398
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 26, 2025
65c99f0
Fix http size issue
zephyranthes03 Sep 26, 2025
c26386d
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 26, 2025
d849e14
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 26, 2025
266d297
Fix http size issue
zephyranthes03 Sep 26, 2025
34e78d6
Fix http size issue
zephyranthes03 Sep 26, 2025
4331e95
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 26, 2025
aa8fb94
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 26, 2025
7b12ca4
Fix http size issue
zephyranthes03 Sep 27, 2025
2260296
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 27, 2025
26c05fc
Fix http size issue
zephyranthes03 Sep 27, 2025
9c2c299
Fix http size issue
zephyranthes03 Sep 27, 2025
4051873
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 27, 2025
cbfca95
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 27, 2025
c640456
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 27, 2025
f19baac
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 27, 2025
fbe4cc7
Fix http size issue
zephyranthes03 Sep 27, 2025
47ebffb
Fix http size issue
zephyranthes03 Sep 27, 2025
37e11f8
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 27, 2025
5098835
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 27, 2025
47ec562
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Sep 27, 2025
3324e59
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Sep 27, 2025
ca16552
Check point for 2024
zephyranthes03 Sep 27, 2025
b5068f1
Check point for 2024
zephyranthes03 Sep 27, 2025
875870b
Check point for 2024 - fmt
zephyranthes03 Sep 27, 2025
32fe89d
Check point for 2024 - dockerfile
zephyranthes03 Sep 27, 2025
c30060c
Check point for streaming/key_id patch
zephyranthes03 Sep 30, 2025
cbafc38
Fix starting process
zephyranthes03 Oct 1, 2025
948f090
Fix mysql auth_token mismatch
zephyranthes03 Oct 1, 2025
eee66c7
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Oct 1, 2025
c1ec243
Fix starting process
zephyranthes03 Oct 1, 2025
ebd3f03
Fix starting process
zephyranthes03 Oct 1, 2025
9e049c7
Migrate DB table
zephyranthes03 Oct 2, 2025
1e8395a
Merge branch 'staging' of github.com:system76/cosmic-sync-server into…
zephyranthes03 Oct 2, 2025
391cb6b
Merge branch 'staging' into fix_rabbit_consumer
zephyranthes03 Oct 2, 2025
f3f332b
Update delete routine
zephyranthes03 Nov 18, 2025
a8d973d
Update delete routine
zephyranthes03 Nov 18, 2025
aa52b24
Merge branch 'origin' into delete_event_v2
zephyranthes03 Nov 18, 2025
6c297a6
Update delete routine
zephyranthes03 Nov 18, 2025
a154cf6
Update delete routine
zephyranthes03 Nov 18, 2025
89e0dd1
Update delete routine
zephyranthes03 Nov 19, 2025
1aa06a3
Update delete routine
zephyranthes03 Nov 19, 2025
24aad96
Merge branch 'staging' into delete_event_v2
zephyranthes03 Nov 19, 2025
c8bb833
Update delete routine
zephyranthes03 Nov 19, 2025
65aa5a1
Update delete routine
zephyranthes03 Nov 19, 2025
d37553f
Update delete routine
zephyranthes03 Nov 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions migrations/sql/20250118_add_reset_monthly_quota_procedure.sql

This file was deleted.

This file was deleted.

75 changes: 72 additions & 3 deletions src/services/file_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,78 @@ impl FileService {
);

if is_deleted {
info!("File is already deleted: file_id={}", file_id);
// Treat as success if already deleted
return Ok(());
warn!(
"⚠️ Client requested deletion of already-deleted file_id={}, checking for actual active file",
file_id
);

// Try to find actual active file by path/name
// This handles the case where client has wrong file_id (from previous deleted file)
// revision=0 means get the latest active file
match self
.storage
.find_file_by_path_and_name(
&file_info.account_hash,
&file_info.file_path,
&file_info.filename,
0, // revision=0: get latest active file (highest revision, not deleted)
)
.await
{
Ok(Some(active_file)) => {
warn!(
"🔄 Found actual active file: old_file_id={}, new_file_id={}, path={}",
file_id, active_file.file_id, file_info.file_path
);
// Delete the actual active file instead
match self
.storage
.delete_file(&active_file.account_hash, active_file.file_id)
.await
{
Ok(_) => {
self.files.lock().await.remove(&active_file.file_id);
info!(
"✅ Successfully deleted actual active file: file_id={}, path={}",
active_file.file_id, file_info.file_path
);

// Send notification for the actual deleted file
if let Some(nm) = &self.notification_manager {
let notification = FileUpdateNotification {
account_hash: active_file.account_hash.clone(),
device_hash: active_file.device_hash.clone(),
file_info: Some(active_file.to_sync_file()),
update_type: crate::sync::file_update_notification::UpdateType::Deleted as i32,
timestamp: chrono::Utc::now().timestamp(),
rename_info: None,
};
let _ = nm.broadcast_file_update(notification).await;
}

return Ok(());
}
Err(e) => {
error!(
"Failed to delete actual active file: file_id={}, error={}",
active_file.file_id, e
);
return Err(e);
}
}
}
Ok(None) => {
info!("No active file found with same path, file is truly deleted: file_id={}", file_id);
return Ok(());
}
Err(e) => {
warn!(
"Error searching for active file: {}, treating as already deleted",
e
);
return Ok(());
}
}
}

// Handle file deletion
Expand Down
10 changes: 7 additions & 3 deletions src/storage/mysql_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ impl MySqlFileExt for MySqlStorage {
// Check if file exists and belongs to the user
// Use Vec<u8> for VARBINARY columns (file_path, filename)
let row_opt = sqlx::query(
r#"SELECT file_id, revision, file_path, filename, device_hash, group_id, watcher_id
r#"SELECT file_id, revision, file_path, filename, device_hash, group_id, watcher_id, server_group_id, server_watcher_id
FROM files WHERE file_id = ? AND account_hash = ?"#,
)
.bind(file_id)
Expand Down Expand Up @@ -800,6 +800,8 @@ impl MySqlFileExt for MySqlStorage {
let device_hash: String = row.try_get("device_hash").unwrap_or_default();
let group_id: i32 = row.try_get("group_id").unwrap_or(0);
let watcher_id: i32 = row.try_get("watcher_id").unwrap_or(0);
let server_group_id: i32 = row.try_get("server_group_id").unwrap_or(0);
let server_watcher_id: i32 = row.try_get("server_watcher_id").unwrap_or(0);

let new_revision = current_revision + 1;

Expand Down Expand Up @@ -859,8 +861,8 @@ impl MySqlFileExt for MySqlStorage {
// Use Vec<u8> for VARBINARY columns to avoid type mismatch
sqlx::query(
r#"INSERT INTO files
(file_id, account_hash, device_hash, file_path, filename, file_hash, size, unix_permissions)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)"#,
(file_id, account_hash, device_hash, file_path, filename, file_hash, size, unix_permissions, server_group_id, server_watcher_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"#,
)
.bind(new_file_id)
.bind(account_hash)
Expand All @@ -870,6 +872,8 @@ impl MySqlFileExt for MySqlStorage {
.bind(&file_path_bytes) // file_hash uses file_path_bytes
.bind(0i64)
.bind(None::<u32>)
.bind(server_group_id)
.bind(server_watcher_id)
.execute(&mut *tx)
.await
.map_err(|e| StorageError::Database(format!("Deletion history addition failed (step 1, schema/VARBINARY type mismatch): {}", e)))?;
Expand Down