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

Prevent duplicating config files with multiple writes #1467

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

### Improvements
- Log and recover from occasional openslide failures ([#1461](../../pull/1461))
- Add support for Imaging Data Commons ([#1450](../../pull/1450))

### Changes
- Make GDAL an optional dependency for the converter ([#1464](../../pull/1464))

### Bug Fixes
- Fix an issue with uniform band depth on multi source with non uniform sources ([#1459](../../pull/1459))
- Fix histogram request bug in band compositing mode ([#1463](../../pull/1463))
- Prevent duplicating config files with multiple writes ([#1467](../../pull/1467))

## 1.27.2

Expand Down
22 changes: 16 additions & 6 deletions girder/girder_large_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import datetime
import json
import re
import threading
import warnings
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
Expand Down Expand Up @@ -60,6 +61,7 @@


mimetypes = None
_configWriteLock = threading.RLock()


# Girder 3 is pinned to use pymongo < 4; its warnings aren't relevant until
Expand Down Expand Up @@ -496,12 +498,20 @@ def yamlConfigFileWrite(folder, name, user, yaml_config):
yaml.safe_load(yaml_config)
item = Item().createItem(name, user, folder, reuseExisting=True)
existingFiles = list(Item().childFiles(item))
upload = Upload().createUpload(
user, name, 'item', item, size=len(yaml_config), mimeType='text/yaml',
save=True)
Upload().handleChunk(upload, yaml_config)
for file in existingFiles:
File().remove(file)
if (len(existingFiles) == 1 and
existingFiles[0]['mimeType'] == 'text/yaml' and
existingFiles[0]['name'] == name):
upload = Upload().createUploadToFile(
existingFiles[0], user, size=len(yaml_config))
else:
upload = Upload().createUpload(
user, name, 'item', item, size=len(yaml_config),
mimeType='text/yaml', save=True)
newfile = Upload().handleChunk(upload, yaml_config)
with _configWriteLock:
for entry in list(Item().childFiles(item)):
if entry['_id'] != newfile['_id'] and len(Item().childFiles(item)) > 1:
File().remove(entry)


# Validators
Expand Down