Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not remove the local cached image if it wasn't removed on the s3 bucket #232

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions .github/workflows/Linux-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,21 @@ jobs:
symbol: jammy,
arch: amd64
}

- {
name: ubuntu-24.04,
os: ubuntu,
symbol: noble,
arch: amd64
}

steps:
- name: Enable Docker Experimental Features
run: |
echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
mkdir -p ~/.docker
echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json
sudo service docker restart
docker version -f '{{.Client.Experimental}}'
docker version -f '{{.Server.Experimental}}'
docker version -f "{{ (index .Server.Components 0).Details.Experimental }}"
docker buildx version
- name: Support for ARM via QEMU's user-mode emulation
# Register binfmt_misc entry for qemu-user-static
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/MacOS-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ env:

jobs:
catalina:
name: macOS Big Sur 11
runs-on: macos-11
name: macOS Monterey 12
runs-on: macos-12

env:
APP_NAME: flameshot
DIR_BULD: build
DIR_PKG: build/src
HELPERS_SCRIPTS_PATH: ../../packaging/macos
# Apple developer identity, example: "Developer ID Application: <user name> (code)"
# Note: no signing and notarization will proceed if this variable is not set
# Note: no signing and notarization will be proceed if this variable is not set
APPLE_DEV_IDENTITY: ${{ secrets.APPLE_DEV_IDENTITY }}
# Apple ID user
APPLE_DEV_USER: ${{ secrets.APPLE_DEV_USER }}
Expand All @@ -45,22 +45,19 @@ jobs:

steps:
- name: Checkout Source code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Install Qt
run: brew install qt@5 cmake

- name: Configure
run: |
mkdir -p "${DIR_BULD}"
cd "${DIR_BULD}"
rm -rf ./src/flameshot.dmg ./src/flameshot.app/
cmake .. -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 -DUSE_MONOCHROME_ICON=True
rm -rf "${DIR_BULD}"/src/flameshot.dmg "${DIR_BULD}"/src/flameshot.app/
cmake -S . -B "${DIR_BULD}" -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 -DUSE_MONOCHROME_ICON=True

- name: Compile
run: |
cd "${DIR_BULD}"
make
cmake --build "${DIR_BULD}"

- name: Create key-chain and import certificate
run: |
Expand All @@ -81,7 +78,7 @@ jobs:
echo "=====no operation for you can see link in the log console====="

- name: Artifact Upload
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: MacOS-artifact
path: ${{ github.workspace }}/build/src/flameshot.dmg
Expand All @@ -94,4 +91,4 @@ jobs:
else
echo "::warning Notarization check failed"
# exit 1
fi
fi
8 changes: 8 additions & 0 deletions src/tools/imgupload/storages/imguploaderbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,11 @@ void ImgUploaderBase::saveScreenshotToFilesystem()
}
m_notification->showMessage(tr("Screenshot saved."));
}

void ImgUploaderBase::removeCacheFile(const QString& fullFileName)
{
QFile file(fullFileName);
if (file.exists()) {
file.remove();
}
}
3 changes: 3 additions & 0 deletions src/tools/imgupload/storages/imguploaderbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ private slots:
void deleteCurrentImage();
void saveScreenshotToFilesystem();

protected:
void removeCacheFile(const QString& fullFileName);

private:
QPixmap m_pixmap;

Expand Down
4 changes: 4 additions & 0 deletions src/tools/imgupload/storages/imgur/imguruploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ void ImgurUploader::deleteImage(const QString& fileName,
notification()->showMessage(tr("Unable to open the URL."));
}

History history;
QString fullFileName = history.path() + fileName;
removeCacheFile(fullFileName);

emit deleteOk();
}
19 changes: 5 additions & 14 deletions src/tools/imgupload/storages/s3/imgs3uploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@ void ImgS3Uploader::onUploadError(QNetworkReply* reply)

void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply* reply)
{
// Just remove image preview on fail because it can be outdated and removed
// on server.
removeImagePreview();
close();

/* The following code possibly will be required later so it is just
* commented here */
auto replyError = reply->error();
if (replyError == QNetworkReply::NoError) {
removeImagePreview();
Expand Down Expand Up @@ -374,14 +367,12 @@ void ImgS3Uploader::removeImagePreview()
{
// remove local file
History history;
QString packedFileName = history.packFileName(
SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, m_storageImageName);
QString fullFileName = history.path() + packedFileName;
QString fullFileName =
history.path() + history.packFileName(SCREENSHOT_STORAGE_TYPE_S3,
m_deleteToken,
m_storageImageName);

QFile file(fullFileName);
if (file.exists()) {
file.remove();
}
removeCacheFile(fullFileName);
m_deleteToken.clear();
m_storageImageName.clear();
resultStatus = true;
Expand Down
9 changes: 0 additions & 9 deletions src/widgets/uploadlineitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
#include <QUrl>
#include <QWidget>

void removeCacheFile(QString const& fullFileName)
{
QFile file(fullFileName);
if (file.exists()) {
file.remove();
}
}

UploadLineItem::UploadLineItem(QWidget* parent,
QPixmap const& preview,
QString const& timestamp,
Expand Down Expand Up @@ -58,7 +50,6 @@ UploadLineItem::UploadLineItem(QWidget* parent,
ImgUploaderManager(this).uploader(unpackFileName.type);
imgUploaderBase->deleteImage(unpackFileName.file, unpackFileName.token);

removeCacheFile(fullFileName);
emit requestedDeletion();
});
}
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/uploadlineitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class UploadLineItem;
}
QT_END_NAMESPACE

void removeCacheFile(QString const& fullFileName);

class UploadLineItem : public QWidget
{
Q_OBJECT
Expand Down
Loading