|
4 | 4 | import fnmatch |
5 | 5 | import os |
6 | 6 | import tempfile |
| 7 | +import uuid |
7 | 8 | import zipfile |
8 | 9 |
|
9 | 10 | import boto3 |
@@ -338,11 +339,11 @@ def process_quadrant(self, indexrange, zoom): |
338 | 339 |
|
339 | 340 | # Compute quadrant bounds and create destination file |
340 | 341 | bounds = utils.tile_bounds(indexrange[0], indexrange[1], zoom) |
341 | | - dest_file = tempfile.NamedTemporaryFile(dir=self.tmpdir, suffix='.tif', delete=False) |
| 342 | + dest_file_name = os.path.join(self.tmpdir, '{}.tif'.format(uuid.uuid4())) |
342 | 343 |
|
343 | 344 | # Snap dataset to the quadrant |
344 | 345 | snapped_dataset = self.dataset.warp({ |
345 | | - 'name': dest_file.name, |
| 346 | + 'name': dest_file_name, |
346 | 347 | 'origin': [bounds[0], bounds[3]], |
347 | 348 | 'scale': [tilescale, -tilescale], |
348 | 349 | 'width': (indexrange[2] - indexrange[0] + 1) * self.tilesize, |
@@ -409,7 +410,7 @@ def process_quadrant(self, indexrange, zoom): |
409 | 410 | RasterTile.objects.bulk_create(batch) |
410 | 411 |
|
411 | 412 | # Remove quadrant raster tempfile. |
412 | | - os.remove(dest_file.name) |
| 413 | + os.remove(dest_file_name) |
413 | 414 |
|
414 | 415 | def push_histogram(self, data): |
415 | 416 | """ |
|
0 commit comments