diff --git a/common/thumbnailer.go b/common/thumbnailer.go index 876b73bf..c2b9a259 100644 --- a/common/thumbnailer.go +++ b/common/thumbnailer.go @@ -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 diff --git a/docs/installation.md b/docs/installation.md index 40ac6262..55b9e5e9 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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` diff --git a/public/global.js b/public/global.js index d319c212..37562088 100644 --- a/public/global.js +++ b/public/global.js @@ -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) => { diff --git a/routes/account.go b/routes/account.go index 25e49536..a7da3215 100644 --- a/routes/account.go +++ b/routes/account.go @@ -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 {