The following link provides information about how Transifex handles updates of a resource file:
https://dev.befoolish.co/tx-docs/public/projects/updating-content#what-happens-when-you-update-files
507245
function updateResource(project, slug, xlfFile, apiHostname, credentials) {
    return new Promise((resolve, reject) => {
        const data = JSON.stringify({ content: xlfFile.contents.toString() });
        const options = {
            hostname: apiHostname,
            path: `/api/2/project/${project}/resource/${slug}/content`,
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': Buffer.byteLength(data)
            },
            auth: credentials,
            method: 'PUT'
        };
        let request = https.request(options, (res) => {
            if (res.statusCode === 200) {
                res.setEncoding('utf8');
                let responseBuffer = '';
                res.on('data', function (chunk) {
                    responseBuffer += chunk;
                });
                res.on('end', () => {
                    const response = JSON.parse(responseBuffer);
                    log(`Resource ${project}/${slug} successfully updated on Transifex. Strings added: ${response.strings_added}, updated: ${response.strings_added}, deleted: ${response.strings_added}`);
                    resolve();
                });
            }
            else {
                reject(`Something went wrong in the request updating ${slug} in ${project}. ${res.statusCode}`);
            }
        });
        request.on('error', (err) => {
            reject(`Failed to update ${project}/${slug} on Transifex: ${err}`);
        });
        request.write(data);
        request.end();
    });
}
165148
def updateStatus(self, logical_file_name, is_file_valid, lost, dataset):
        

        conn = self.dbi.connection()
        trans = conn.begin()
        try :
            self.updatestatus.execute(conn, logical_file_name, is_file_valid, lost, dataset, trans)
            trans.commit()
            trans = None
        except Exception as ex:
            if trans:
                trans.rollback()
                trans = None
            raise ex

        finally:
            if trans:
                trans.rollback()
            if conn:
                conn.close()
338108
private function updateWebResourceFilePath()
    {
        $this->log('Update resourceWeb file path ...');

        /** @var ObjectManager $om */
        $om = $this->container->get('claroline.persistence.object_manager');
        $resourceType = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceType')->findOneBy(['name' => 'claroline_web_resource']);
        $resourceNodes = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceNode')->findBy(['resourceType' => $resourceType]);
        $resourceManager = $this->container->get('claroline.manager.resource_manager');
        $fs = $this->container->get('filesystem');

        foreach ($resourceNodes as $resourceNode) {
            $file = $resourceManager->getResourceFromNode($resourceNode);
            $workspace = $resourceNode->getWorkspace();

            if (!empty($file)) {
                $hash = $file->getHashName();
                $uploadDir = $this->container->getParameter('claroline.param.uploads_directory');
                $filesDir = $this->container->getParameter('claroline.param.files_directory');

                if ($fs->exists($filesDir.DIRECTORY_SEPARATOR.$hash)) {
                    $fs->copy($filesDir.DIRECTORY_SEPARATOR.$hash, $filesDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash);
                    $fs->remove($filesDir.DIRECTORY_SEPARATOR.$hash);
                }

                if ($fs->exists($uploadDir.DIRECTORY_SEPARATOR.$hash)) {
                    $fs->mirror($uploadDir.DIRECTORY_SEPARATOR.$hash, $uploadDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash);
                    $fs->remove($uploadDir.DIRECTORY_SEPARATOR.$hash);
                }
            }
        }
    }
277809
function(resource, opts) {
      if (this.debugMode) log('update', { resource: resource, opts: opts })
      resource._update(this, resource, opts)
    }
1339807
function updatePluginResourceRequirePath(file, moduleConfig, pluginResPackInfo) {
    file.setContent(amdHelper.updateResourceId(
        file.getContent(),
        function (resId, moduleInfo, isAsynDep) {
            if (resId.indexOf('!') === -1) {
                return resId;
            }

            var moduleId = moduleInfo.id
                || amdHelper.getModuleId(file.id, moduleConfig, true);
            if (!moduleId) {
                return resId;
            }

            var resInfo = amdHelper.getResourceInfo(
                resId, isAsynDep ? null : moduleId, moduleConfig
            );
            var resFileInfo = pluginResPackInfo[resInfo.pluginResource.path];
            if (resFileInfo) {
                var pkg = resFileInfo.packTo.pkg;
                var pluginResId = amdHelper.getResourceId(
                    pkg.realpath, moduleConfig, true
                );
                return resInfo.module.rawId + '!' + pluginResId;
            }

            return resId;
        }
    ));
}
114124
public function actionUpdate()
    {
        
        $this->outVerbose("Updating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'...");
        $sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
        
       	// Get virgin translations from the source code and manifest.
       	$filePaths = array();
        foreach (self::$WHITE_LIST as $subFolder) {
            $filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
        }
        
       	$extensions = array('php', 'tpl', 'js', 'ejs');
       	$sourceCodeExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $extensions);
       	$sourceCodeExtractor->extract();
    	
       	$translationFile = new tao_helpers_translation_POFile();
        $translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        $translationFile->setTargetLanguage($this->options['language']);
       	$translationFile->addTranslationUnits($sourceCodeExtractor->getTranslationUnits());
       	
        $file = MenuService::getStructuresFilePath($this->options['extension']);
        if (!is_null($file)) {
            $structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
           	$structureExtractor->extract();
            $structureUnits = $structureExtractor->getTranslationUnits();
            $this->outVerbose(count($structureUnits) . ' units extracted from structures.xml.');
            $translationFile->addTranslationUnits($structureUnits);
        }

       	// For each TU that was recovered, have a look in an older version
       	// of the translations.
       	$oldFilePath = $this->buildLanguagePath($this->options['extension'], $this->options['language']) . '/' .self::DEF_PO_FILENAME;
       	$translationFileReader = new tao_helpers_translation_POFileReader($oldFilePath);
       	$translationFileReader->read();
       	$oldTranslationFile = $translationFileReader->getTranslationFile();
       	
       	foreach ($oldTranslationFile->getTranslationUnits() as $oldTu) {
       		if (($newTu = $translationFile->getBySource($oldTu)) !== null && $oldTu->getTarget() != '') {
       			// No duplicates in TFs so I simply add it whatever happens.
       			// If it already has the same one, it means we will update it.
       			$newTu->setTarget($oldTu->getTarget());
       		}
       	}
        
       	$sortedTranslationFile = new tao_helpers_translation_POFile();
        $sortedTranslationFile->setSourceLanguage($translationFile->getSourceLanguage());
        $sortedTranslationFile->setTargetLanguage($translationFile->getTargetLanguage());
       	$sortedTranslationFile->addTranslationUnits($translationFile->sortBySource($sortingMethod));
       	$this->preparePOFile($sortedTranslationFile, true);
       	
       	// Write the new ones.
       	$poFileWriter = new tao_helpers_translation_POFileWriter($oldFilePath, $sortedTranslationFile);
       	$poFileWriter->write();
        $this->outVerbose("PO translation file '" . basename($oldFilePath) . "' in '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");

		$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);

		// We now deal with RDF models.
        foreach ($this->getOntologyFiles() as $f){
                // Loop on 'master' models.
				$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);

                // The slave RDF file is the translation of the ontology that we find in /extId/Locales/langCode.
                $slavePOFilePath = $this->buildLanguagePath($this->options['extension'], $this->options['language']) . '/' . $this->getOntologyPOFileName($f);
                if (file_exists($slavePOFilePath)){
                    // Read the existing RDF Translation file for this RDF model.
                    $poReader = new tao_helpers_translation_POFileReader($slavePOFilePath);
                    $poReader->read();
                    $slavePOFile = $poReader->getTranslationFile();
                    
                    // Try to update translation units found in the master PO file with
                    // targets found in the old translation of the ontology.
                    foreach ($slavePOFile->getTranslationUnits() as $oTu){
                        $translationFile->addTranslationUnit($oTu);
                    }
                    
                    // Remove Slave PO file. It will be overwritten by the modified Master PO file.
                    tao_helpers_File::remove($slavePOFilePath);
                }
                
                // Write Master PO file as the new Slave PO file.
                $rdfWriter = new tao_helpers_translation_POFileWriter($slavePOFilePath, $translationFile);
                $rdfWriter->write();
                $this->outVerbose("Translation model {$this->getOntologyPOFileName($f)}  in '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
        }
        
       	$this->outVerbose("Language '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
        
    }
756960
def update_file(filename, items):
    '''
    '''
    # TODO: Implement something in the templates to denote whether the value
    # being replaced is an XML attribute or a value. Perhaps move to dyanmic
    # XML tree building rather than string replacement.
    should_escape = filename.endswith('addon.xml')

    with open(filename, 'r') as inp:
        text = inp.read()

    for key, val in items.items():
        if should_escape:
            val = saxutils.quoteattr(val)
        text = text.replace('{%s}' % key, val)
    output = text

    with open(filename, 'w') as out:
        out.write(output)
1129797
def update_file path, matcher, currentVersion, nextVersion
      temp_path = "#{path}.autoversion"

      begin
        File.open(path) do |source|
          File.open(temp_path, 'w') do |target|
            source.each do |line|
              if matcher.call(line)
                target.write line.gsub currentVersion.to_s, nextVersion.to_s
              else
                target.write line
              end
            end
          end
        end

        File.rename temp_path, path
      ensure
        File.unlink temp_path if File.file? temp_path
      end
    end
1038151
protected function updateDB($files, $update_updated = true) {
        $module = \jacmoe\mdpages\Module::getInstance();
        $repo = $this->getFlywheelRepo();

        $filename_pattern = '/\.md$/';

        $metaParser = new Meta;

        $file_action = '';

        foreach ($files as $file) {
            if (!preg_match($filename_pattern, $file)) {
                continue;
            }

            $file_field = substr($file, strlen(Yii::getAlias('@pages')));

            if(!file_exists($file)) {
                // if the post exists, delete it
                $page = $repo->query()->where('file', '==', $file_field)->execute();
                $result = $page->first();
                if($result != null) {
                    echo "File $result->file exists - deleting ..\n";

                    $this->deleteCachekeys($module, $result->url);

                    $repo->delete($result);
                }
                $file_action = 'deleted';
                $this->stdout($file_field . ' was ' . $file_action . "\n");
                continue;
            }

            $metatags = array();
            $metatags = $metaParser->parse(file_get_contents($file));

            $url = $file_field;
            $url = ltrim($url, '/');
            $raw_url = pathinfo($url);
            $url = $raw_url['filename'];
            if($url == 'README') continue;
            if($raw_url['dirname'] != '.') {
                $url = $raw_url['dirname'] . '/' . $url;
            }

            $values = array();

            foreach($metatags as $key => $value) {
                $values[$key] = $value;
            }
            $values['url'] = $url;
            $values['file'] = $file_field;

            list($contributors, $dates) = $this->committersFromFile(ltrim($values['file'],'/'), $module);

            $updated_date = 0;
            $created_date = 0;
            if(isset($values['datetime'])) {
                // work-around for existing page collections
                // where the dates in the commits does not apply
                $updated_date = $values['datetime'];
                $created_date = $values['datetime'];
            } else {
                if(count($dates) === 1) {
                    $updated_date = $dates[0];
                    $created_date = $dates[0];
                } else {
                    $updated_date = end($dates);
                    $created_date = reset($dates);
                }
            }

            $file_action = 'created';

            // if the post exists, delete it
            $page = $repo->query()->where('file', '==', $values['file'])->execute();
            $result = $page->first();
            if($result != null) {
                $file_action = 'updated';
                $values['created'] = $result->created;
                $values['updated'] = $update_updated ? $updated_date : $result->updated;

                $this->deleteCachekeys($module, $result->url);

                $repo->delete($result);
            }

            if($file_action == 'created') {
                $values['created'] = $created_date;
                $values['updated'] = $created_date;
            }

            if($module->generate_contributor_data) {
                $values['contributors'] = $contributors;
            }

            $page = new Document($values);
            $repo->store($page);

            $this->stdout($file_field . ' was ' . $file_action . "\n");

        }

    }
188849
def on_change(modified, added, deleted)
      # Modifications and additions are treated the same.
      (modified + added).uniq.each do |path|
        if file = Ichiban::ProjectFile.from_abs(path)
          begin
            @loader.change(file) # Tell the Loader that this file has changed
            file.update
          rescue Exception => exc
            Ichiban.logger.exception(exc)
          end
        end
      end
      
      # Deletions are handled specially.
      deleted.each do |path|
        Ichiban::Deleter.new.delete_dest(path)
      end
      
      # Finally, propagate this change to any dependent files.
      (modified + added + deleted).uniq.each do |path|
        begin
          Ichiban::Dependencies.propagate(path)
        rescue => exc
          Ichiban.logger.exception(exc)
        end
      end
    end
1003125
private function fileEntityRefreshSettings()
    {
        if ($this->file) {
            // Update settings from the Contact Client entity.
            if (!empty($this->settings['name']) && !$this->file->getLocation()) {
                // Preliminary name containing tokens.
                $this->file->setName($this->settings['name']);
            }
            if (!empty($this->settings['type'])) {
                if (!empty($this->settings['type']['key'])) {
                    $this->file->setType($this->settings['type']['key']);
                }
                if (!empty($this->settings['type']['delimiter'])) {
                    $this->file->setCsvDelimiter($this->settings['type']['delimiter']);
                }
                if (!empty($this->settings['type']['enclosure'])) {
                    $this->file->setCsvEnclosure($this->settings['type']['enclosure']);
                }
                if (!empty($this->settings['type']['escape'])) {
                    $this->file->setCsvEscape($this->settings['type']['escape']);
                }
                if (!empty($this->settings['type']['terminate'])) {
                    $this->file->setCsvTerminate($this->settings['type']['terminate']);
                }
                if (!empty($this->settings['type']['null'])) {
                    $this->file->setCsvNull($this->settings['type']['null']);
                }
            }
            if (isset($this->settings['compression'])) {
                $this->file->setCompression($this->settings['compression']);
            }
            if (isset($this->settings['exclusions'])) {
                $this->file->setExclusions($this->settings['exclusions']);
            }
            if (!empty($this->settings['headers'])) {
                $this->file->setHeaders((bool) $this->settings['headers']);
            }
            if ($this->count) {
                $this->file->setCount($this->count);
                $this->setLogs($this->count, 'count');
            }
            if ($this->scheduleStart) {
                $this->file->setDateAdded($this->scheduleStart);
            }
        }

        return $this;
    }
173260
public function updateFileFormAction(File $file)
    {
        $collection = new ResourceCollection(array($file->getResourceNode()));
        $this->checkAccess('EDIT', $collection);
        $form = $this->get('form.factory')->create(new UpdateFileType(), new File());

        return array(
            'form' => $form->createView(),
            'resourceType' => 'file',
            'file' => $file,
            '_resource' => $file
        );
    }
656974
def resource_collections_update(self, data, **kwargs):
        ""
        api_path = "/api/v2/resource_collections.json"
        return self.call(api_path, method="PUT", data=data, **kwargs)
62825
def _update(self, **kwargs):
        """"""
        if 'content' in kwargs:
            content = kwargs.pop('content')
            path = self._construct_path_to_source_content()
            self._http.put(path, json.dumps({'content': content}))
        super(Resource, self)._update(**kwargs)
821231
public function updateDb()
    {
        $this->createUpdateTableIfNotExists();
        $this->getProcessedFiles();
        
        $path = leedch_resourceMysqlUpdateFolder;
        $files = $this->findNewFiles($path);
        
        $this->processNewFiles($files);
    }
1338333
function(peer, data, chunkIdx, fileObj, isLastChunk, updateProgress, emit){
  if (fileObj.fileWriter) { // todo, when the whole file is done writing, remove this fileWriter on fileObj(in tasks)
    doWriting(fileObj.fileWriter, fileObj, peer, chunkIdx, data, isLastChunk, updateProgress, emit);
  } else {
    fs(fileObj).then(fileExists).then(getFile).then(getFileWriter).then(function(writer) {
      doWriting(writer, fileObj, peer, chunkIdx, data, isLastChunk, updateProgress, emit);
    }, function(err) {
      emit('error/file', new FilerError({
        name: 'ChromeFileSystemError', code: "ERR_CHROME_FILESYSTEM_ERROR",  message: err.message || 'failed to get FileSystem Writer',
        peerID: peer._peerID, fileID: fileObj.fileID
      }));
      fileObj.fileWriter = null;
    });
  }
}
522197
function _shouldKeepExisting(file, text)
{
return Promise.coroutine(function *() {
	if (!(yield fs.fileExists(file)))
		return false;

//	var st = yield fs.stat(file);
//	if (st > _ThisBuild)
//		l.logw("File is used multiple times: '" + file)+"'");

	// read the existing file and compare with new contents. ignore if nothing changed
	try
	{
		var existingText = yield fs.readFile(file, "utf8");
		if (existingText == text)
		{
			//l.vlog("Skipping (unchanged): '" + file + "'");
			return true;
		}
	}
	catch (e)
	{
		l.logw("Failed to compare existing file " + path.basename(file) + " (will try and overwrite): " + _.niceStackTrace(e));
		// and continue below...
	}
	return false;
})();
}