Open stypr opened 1 year ago
I found the solution, but this issue still needs to be fixed.
The problem was that the fileinfo
table was originally from Mattermost, and for some reason, it's still referencing fileinfo
relation on file deletion.
As for a temporary fix, I've used the migration sql from Mattermost's Migrations -- it works nicely for postgres, but needs to checked if the fix works for mysql.
[Update] Even with the temporary fix, the file doesn't get deleted from the storage. it's just the record that gets deleted from the database..
CREATE TABLE IF NOT EXISTS fileinfo (
id VARCHAR(26) PRIMARY KEY,
creatorid VARCHAR(26),
postid VARCHAR(26),
createat bigint,
updateat bigint,
deleteat bigint,
path VARCHAR(512),
thumbnailpath VARCHAR(512),
previewpath VARCHAR(512),
name VARCHAR(256),
extension VARCHAR(64),
size bigint,
mimetype VARCHAR(256),
width integer,
height integer,
haspreviewimage boolean
);
CREATE INDEX IF NOT EXISTS idx_fileinfo_update_at ON fileinfo (updateat);
CREATE INDEX IF NOT EXISTS idx_fileinfo_create_at ON fileinfo (createat);
CREATE INDEX IF NOT EXISTS idx_fileinfo_delete_at ON fileinfo (deleteat);
CREATE INDEX IF NOT EXISTS idx_fileinfo_postid_at ON fileinfo (postid);
CREATE INDEX IF NOT EXISTS idx_fileinfo_extension_at ON fileinfo (extension);
CREATE INDEX IF NOT EXISTS idx_fileinfo_name_txt ON fileinfo USING gin(to_tsvector('english', name));
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS minipreview bytea;
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS content text;
CREATE INDEX IF NOT EXISTS idx_fileinfo_content_txt ON fileinfo USING gin(to_tsvector('english', content));
CREATE INDEX IF NOT EXISTS idx_fileinfo_name_splitted ON fileinfo USING gin (to_tsvector('english'::regconfig, translate((name)::text, '.,-'::text, ' '::text)));
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS remoteid varchar(26);
ALTER TABLE fileinfo OWNER TO focalboard;
Found few fixes, someone can do a PR or just fix it locally.
/services/store/sqlstore/blocks.go
)
Without this the deletion never works because fileIDExists
and attachmentIDExists
will always exist on newer version. (it's not nil
, it's ""
)func retrieveFileIDFromBlockFieldStorage(id string) string {
parts := strings.Split(id, ".")
if len(parts) < 1 {
return ""
}
return parts[0][1:]
}
needs to be changed to
func retrieveFileIDFromBlockFieldStorage(id string) string {
if id == "" {
return ""
}
parts := strings.Split(id, ".")
if len(parts) < 1 {
return ""
}
return parts[0][1:]
}
FileInfo
to file_info
(/services/store/sqlstore/blocks.go
)- Update("FileInfo").
- Set("DeleteAt", model.GetMillis()).
+ Update("file_info").
+ Set("delete_at", model.GetMillis()).
Hi, @stypr! I tested the fix linked to https://github.com/stypr/focalboard/commit/e13a2d2d08a4cbf76fcefdc5febe62a4c1d43ca0 but the attachment doesn't get deleted from the storage.
(I also made a diff check between our two blocks.go but they are the same)
Hi, @stypr!
I tested the fix linked to https://github.com/stypr/focalboard/commit/e13a2d2d08a4cbf76fcefdc5febe62a4c1d43ca0 but the attachment doesn't get deleted from the storage.
(I also made a diff check between our two blocks.go but they are the same)
Hi,
yes it's not going to be deleted because there doesnt seem to be an implementation for it.. I'm planning to add that some point but as for now the only way is to implement it by yourself..
Hi, @stypr! I tested the fix linked to stypr@e13a2d2 but the attachment doesn't get deleted from the storage.
(I also made a diff check between our two blocks.go but they are the same)
so I checked a bit more but I confirmed that there is no implementation for this. If you have to delete the file, you have a couple of options
delete_at
> 0 from file_info
table
Steps to reproduce the behavior
Attachment
on boardAttachment
Expected behavior
File needs to be deleted and queries need to be executed as expected.
Current behavior
File does not get deleted. Cards with attachments will never be deleted.
The log show that the
relation `fileinfo` does not exist.
.Edition and Platform
Additional context
I think the focalboard was using
fileinfo
relation in the past. but now it seems to be replaced tofile_info
. (Correct me if I'm wrong) I don't really know whyfileinfo
is still used whenfile_info
exists.psql log relation list