Delete old avatar files to avoid dead files from building up in /uploads/ and potentially causing issues.
Make the thumbnailer more resiliant when the avatar it's supposed to be thumbnailing doesn't exist. /uploads/ should be set to 2755 to reduce the probability of permission issues. WebSockets now re-connects after a while after the connection drops. This is slightly experimental.
This commit is contained in:
parent
a28b6c2690
commit
836a148ee8
|
@ -31,6 +31,14 @@ func ThumbTask(thumbChan chan bool) {
|
|||
_, _ = acc.Delete("users_avatar_queue").Where("uid = ?").Run(uid)
|
||||
return nil
|
||||
}
|
||||
_, err = os.Stat("./uploads/avatar_" + strconv.Itoa(user.ID) + user.RawAvatar)
|
||||
if os.IsNotExist(err) {
|
||||
_, _ = acc.Delete("users_avatar_queue").Where("uid = ?").Run(uid)
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
// This means it's an external image, they aren't currently implemented, but this is here for when they are
|
||||
if user.RawAvatar[0] != '.' {
|
||||
return nil
|
||||
|
|
|
@ -74,6 +74,8 @@ Type in a strong password for the `gosora` user, please oh please... Don't use "
|
|||
|
||||
`chmod 2775 logs`
|
||||
|
||||
`chmod 2775 uploads`
|
||||
|
||||
`chmod 755 ./install-linux`
|
||||
|
||||
`./install-linux`
|
||||
|
|
|
@ -173,6 +173,7 @@ function runWebSockets() {
|
|||
console.log(err);
|
||||
}
|
||||
|
||||
// TODO: Sync alerts, topic list, etc.
|
||||
conn.onopen = () => {
|
||||
console.log("The WebSockets connection was opened");
|
||||
conn.send("page " + document.location.pathname + '\r');
|
||||
|
@ -185,6 +186,7 @@ function runWebSockets() {
|
|||
conn.onclose = () => {
|
||||
conn = false;
|
||||
console.log("The WebSockets connection was closed");
|
||||
setTimeout(() => runWebSockets(), 60 * 1000);
|
||||
}
|
||||
|
||||
conn.onmessage = (event) => {
|
||||
|
|
|
@ -506,6 +506,23 @@ func AccountEditAvatarSubmit(w http.ResponseWriter, r *http.Request, user common
|
|||
if err != nil {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
// Clean up the old avatar data, so we don't end up with too many dead files in /uploads/
|
||||
if len(user.RawAvatar) > 2 {
|
||||
if user.RawAvatar[0] == '.' && user.RawAvatar[1] == '.' {
|
||||
err := os.Remove("./uploads/avatar_" + strconv.Itoa(user.ID) + "_tmp" + user.RawAvatar[1:])
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
common.LogWarning(err)
|
||||
return common.LocalError("Something went wrong", w, r, user)
|
||||
}
|
||||
err = os.Remove("./uploads/avatar_" + strconv.Itoa(user.ID) + "_w48" + user.RawAvatar[1:])
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
common.LogWarning(err)
|
||||
return common.LocalError("Something went wrong", w, r, user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Only schedule a resize if the avatar isn't tiny
|
||||
err = user.ScheduleAvatarResize()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue